Phpmailer is a free PHP mail send plug-in, we can use Phpmailer login to our designated mail and then use this email to us automatically email, this now free mailbox like 163,sina support, All right, crap don't say much. To see a phpmainer 163 email it.
It's a good choice to send mail with an out-of-the-box SMTP server, which is Phpmailer (Version 5.2.0) and the SMTP server for Gmail and 163.
1. Scripts sent with Gmail
Include ("class.phpmailer.php"); Include ("class.smtp.php");//Gets the contents of an external file $mail = new Phpmailer (); $body = File_get _contents (' contents.html '); $body = Eregi_replace ("[\]", "", $body);//Set SMTP parameter $MAIL->ISSMTP (); $mail->smtpauth = true; $mail->smtpkeepalive = true; $mail->smtpsecure = "SSL"; $mail->host = "smtp.gmail.com"; $mail->port = 465;//fill in your Gmail account and password $mail->username = "yourname@gmail.com"; $mail->password = "Password";//Set the sender, preferably do not forge the address $ Mail->from = "yourname@gmail.com"; $mail->fromname = "Webmaster"; $mail->subject = "This is the Subject"; $mail ->altbody = $body; $mail->wordwrap = 50; Set Word wrap$mail->msghtml ($body);//sets the reply address $mail->addreplyto ("yourname@gmail.com", "Webmaster");//Add attachments, Here the attachment is in the same directory as the script//otherwise fill in the full path $mail->addattachment ("Attachment.jpg"); $mail->addattachment ("Attachment.zip");// Set the mail receiver's mailbox and name $mail->addaddress ("toname@gmail.com", "FirstName LastName");//send mail using HTML format $mail->ishtml (TRUE) ;//Send mail via Send method//according toSend the result to do the appropriate processing if (! $mail->send ()) {echo "Mailer Error:". $mail->errorinfo;} else {echo "Message has been sent";}
2. Use 163 scripts to send messages
You only need to change your SMTP configuration and account password, and the SMTP configuration is as follows
Set SMTP parameters//Note there is no need for SSL protocol $mail->issmtp (); $mail->smtpauth = true; $mail->smtpkeepalive = true; $mail- >host = "smtp.163.com"; $mail->port = 25;
Test pass in local wampserver environment, need to open Php_openssl extension.
Summary : The above is the entire content of this article, I hope to be able to help you learn.
Related recommendations:
PHP operation MySQL Database and Session dialog method
PHP three common techniques for traversing trees
Definition and usage of Phpzip class