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