PHPMailer: FeaturedemailtransferclassforPHP

Source: Internet
Author: User
Tags word wrap one mail qmail
PhpMailer: FeaturedemailtransferclassforPHPPHPMailer is a useful PHP mail class. It supports sending mails using the smtp server, and supports mail servers such as Sendmail, qmail, Postfix, Imail, Exchange, Mercury, and Courier. If the SMTP server is still phpMailer: Featured email transfer class for PHP
PHPMailer is a useful PHP mail class. It supports sending mails using the smtp server, and supports mail servers such as Sendmail, qmail, Postfix, Imail, Exchange, Mercury, and Courier. The SMTP server also supports authentication and multiple SMTP sending (but it is not clear what is the use ). email sending can include multiple TO, CC, BCC and REPLY-TO, supports text and HTML mail formats, can automatically wrap, supports attachments and images in various formats, customize the basic mail functions of the mail class.

Because PHP only contains one mail function, PHPMailer is greatly enhanced. I believe it can meet the needs of many people. It mainly includes two types of files: class. phpmailer. php for mail sending and class. smtp. php for smtp. There are also files that can implement multiple error outputs, as well as detailed documents. Software release follows the LGPL protocol.

It's easy to use. you can see the following example:

Require ("class. phpmailer. php ");

$ Mail = new PHPMailer ();

$ Mail-> IsSMTP (); // send via SMTP
$ Mail-> Host = "smtp1.site.com; smtp2.site.com"; // SMTP servers
$ Mail-> SMTPAuth = true; // turn on SMTP authentication
$ Mail-> Username = "jswan"; // SMTP username
$ Mail-> PassWord = "secret"; // SMTP password
'Www .cncms.com
$ Mail-> From = "from@email.com ";
$ Mail-> FromName = "Mailer ";
$ Mail-> AddAddress ("josh@site.com", "Josh Adams ");
$ Mail-> AddAddress ("ellen@site.com"); // optional name
$ Mail-> AddReplyTo ("info@site.com", "Information ");

$ Mail-> WordWrap = 50; // set word wrap
$ Mail-> AddAttachment ("/var/tmp/file.tar.gz"); // attachment
$ Mail-> AddAttachment ("/tmp/image.jpg", "new.jpg ");
$ Mail-> IsHTML (true); // send as HTML

$ Mail-> Subject = "Here is the subject ";
$ Mail-> Body = "This isHTML body";
$ Mail-> AltBody = "This is the text-only body ";

If (! $ Mail-> Send ())
{
Echo "Message was not sent

";
Echo "Mailer Error:". $ mail-> ErrorInfo;
Exit;
}

Echo "Message has been sent ";


For more information, see PHPMailer homepage: http://phpmailer.sourceforge.net/

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.