PHPMailer installation method and simple instance _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.