PHP sends mail with Phpmailer, Phpmailer sends mail
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.
The above mentioned is the whole content of this article, I hope you can like.
http://www.bkjia.com/PHPjc/997913.html www.bkjia.com true http://www.bkjia.com/PHPjc/997913.html techarticle PHP with Phpmailer to send mail, phpmailer send mail local no mail server, the use of ready-made SMTP server to send mail is a good choice, the tool used here is ...