PHP Email: swiftmailer, PHP Mail library--swiftmailer

Source: Internet
Author: User
Tags php email

PHP Email: swiftmailer, PHP Mail library--swiftmailer

Recently saw a good PHP mail library, like Phpmailer role, but performance than Phpmailer, especially in the ability to handle attachments, send mail success is also high.

GitHub Address: Https://github.com/swiftmailer/swiftmailer.git

Require_once ("lib/swift_required.php");//Create transport object, set mail server and port number, and set user name and password for authentication $transport = Swift_smtptransport :: Newinstance (' smtp.163.com ', +)->setusername (' [email protected] ')->setpassword (' password ');// Create Mailer Object $mailer = Swift_mailer::newinstance ($transport);//Create Message Object $message = Swift_message::newinstance ();//    Set the message subject $message->setsubject (' This is a test message ')//Set the message content, you can omit Content-type->setbody (' 

  

Test code, test examples:

$Requests = __dir__. ‘/.. /.. /.. /vendor/swiftmailer/swiftmailer/lib/swift_required.php ';        Require_once ($Requests);        Requests::register_autoloader ();//Create transport object, set mail server and port number, and set user name and password for authentication $transport = \swift_smtptransport:: Newinstance (' smtp.exmail.qq.com ', +)->setusername (' [email protected] ')->setpassword (' Youxikaishi04 ');// Create Mailer Object $mailer = \swift_mailer::newinstance ($transport);//Create Message Object $message = \swift_message::newinstance (); /Set the message subject $message->setsubject (' This is a test message ')->setbody (' aaaa ');/////////Set the recipient address with an associative array, you can set multiple recipients $message->setto ( Array (' [email protected] ' = ' muyang '));//Set the sender address with an associative array, you can set multiple senders $message->setfrom (' [email protected] ' = > ' Shandongair ');//Send mail $result = $mailer->send ($message);       echo "AAA";   Exit

  

PHP e-mail: Swiftmailer, PHP mail base--swiftmailer

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.