PHPMailer installation method and simple instance. Open PHP in your computer. in the INI file, locate the following location and add the content in the red line. The path is where your PHPMailer is stored: Save and restart apache. use one of readme to open your computer's PHP. in the INI file, locate the following location and add the content in the red line. The path is where your PHPMailer is stored:
Save and restart apache.
I can use the example in readme to make a few changes. I have commented out many things because I only perform the simplest test.
Send. php
The code is as follows:
Require ("class. phpmailer. php ");
$ Mail = new PHPMailer ();
$ Address = $ _ POST ['address'];
$ Mail-> IsSMTP (); // set mailer to use SMTP
$ Mail-> Host = "mail.songzi.org"; // specify main and backup server
$ Mail-> SMTPAuth = true; // turn on SMTP authentication
$ Mail-> Username = "phpmailer@songzi.org"; // SMTP username
$ Mail-> Password = "******"; // SMTP password
$ Mail-> From = "phpmailer@songzi.org ";
$ Mail-> FromName = "songzi ";
$ Mail-> AddAddress ("$ address ","");
// $ Mail-> AddAddress (""); // name is optional
// $ Mail-> AddReplyTo ("","");
// $ Mail-> WordWrap = 50; // set word wrap to 50 characters
// $ Mail-> AddAttachment ("/var/tmp/file.tar.gz"); // add attachments
// $ Mail-> AddAttachment ("/tmp/image.jpg", "new.jpg"); // optional name
// $ Mail-> IsHTML (true); // set email format to HTML
$ Mail-> Subject = "PHPMailer test email ";
$ Mail-> Body = "Hello, this is the test email of pine nuts ";
$ Mail-> AltBody = "This is the body in plain text for non-HTML mail clients ";
If (! $ Mail-> Send ())
{
Echo "Message cocould not be sent.
";
Echo "Mailer Error:". $ mail-> ErrorInfo;
Exit;
}
Echo "Message has been sent ";
?>
Test. php
The code is as follows:
Phpmailer Unit Test
Enter the email address for receiving the email:
Restart to save and restart apache. then borrow one of readme...