I. Brief introduction of Swift Mailer
Swift Mailer is a PHP mail-sending class. It does not rely on the mail () function that comes with PHP because the function consumes a high amount of system resources when sending multiple messages. Swift communicates directly with the SMTP server, with very high transmission speed and efficiency.
Features of Swift Mailer:
1. Use SMTP, SendMail, Postfix, or you can customize the transport implementation to send e-mail
2. Servers requiring user name and password and or encryption support
3, from the head injection attack protection does not request the content of data
4. Send MIME-compatible Html/multipart Mail
5. Use the event-driven plug-in method to customize the library
6. Low memory consumption when handling large attachments and embedded/embedded images
7, Swiftmailer e-mail efficiency is much higher than phpmailer, easy to use.
Ii. Use of Swift Mailer
Require_once ' lib/swift_required.php '; function SendMail () {/* $transport = swift_smtptransport::newinstance (' Smtp.163.com ', $transport->setusername (' username@163.com '); $transport->setpassword (' password '); $ Transport = swift_sendmailtransport::newinstance ('/usr/sbin/exim-bs '); $transport = Swift_mailtransport:: Newinstance (); */$transport = swift_smtptransport::newinstance (' smtp.163.com '); $transport->setusername (' Username@163.com '); $transport->setpassword (' password '); $mailer = Swift_mailer::newinstance ($transport); $ message = Swift_message::newinstance (); $message->setfrom (Array (' username@163.com ' = ' name ')); $message Setto (Array (' whoever@163.com ' = ' mr.right ', ' whoever@qq.com ' = ' mr.wrong ')); $message->setsubject ("This is a subject "); $message->setbody (' Here is the message ', ' text/html ', ' utf-8 '); ' Text/plain ' $message->attach (Swift_attachment::frompath (' pic.jpg ', ' Image/jpeg ')->setfilename (' Rename_ Pic.jpg ') try{$mailer->send ($message);} CatCH (swift_connectionexception $e) {echo ' There is a problem communicating with SMTP: '. $e->getmessage ();}}
Project Address: http://swiftmailer.org/