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. Here is a description of the usage:
1require_once("lib/swift_required.php");23//Create a Transport object, set the mail server and port number, and set the user name and password for authentication4$transport= Swift_smtptransport::newinstance (' smtp.163.com ', 25)5->setusername (' username@163.com ')6->setpassword (' Password ');78//Create a Mailer object9$mailer= Swift_mailer::newinstance ($transport);Ten One//Create a Message object A$message= Swift_message::newinstance (); - -//Set Message subject the$message->setsubject (' This is a test email ') - -//to set the message content, you can omit Content-type --Setbody ( +'' . -'' . +'' . A' Here's an image//Embedded Files at$message->embed (Swift_image::frompath (' image.jpg ')). -' alt= ' share a PHP mail library--swiftmailer "/>". -' Rest of message '. -' Baidu '. -'' . -'', in' Text/html ' -); to +//create Attachment object, Content-type This parameter can be omitted -$attachment= Swift_attachment::frompath (' image.jpg ', ' image/jpeg ') the->setfilename (' cool.jpg '); * $//Add an attachmentPanax Notoginseng$message->attach ($attachment); - the//set the recipient address with an associative array, you can set multiple recipients +$message->setto (Array(' to@qq.com ' = ' toname ')); A the//set the sender's address with an associative array, you can set up more than one sender +$message->setfrom (Array( -' from@163.com ' = ' fromname ', $)); $ -//Add cc person -$message->SETCC (Array( the' Cc@qq.com ' = ' Cc ' - ));Wuyi the//add encryption to send people -$message->SETBCC (Array( Wu' Bcc@qq.com ' = ' Bcc ' -)); About $//set up message receipts -$message->setreadreceiptto (' receipt@163.com '); - -//Send mail A$result=$mailer->send ($message);
The above describes the sharing of a PHP mail library--swiftmailer, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.