A local server that does not send mail is a good choice to send mail with a ready-made SMTP server, the tool used here is Phpmailer (Version 5.2.0), and the SMTP server chooses Gmail and 163.
1. Use Gmail to send the script
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 Parameters $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, it is best not to 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);
Set the reply address $mail->addreplyto ("yourname@gmail.com", "webmaster");
Add attachments, where the attachment is in the same directory as the script//otherwise fill out the full path $mail->addattachment ("attachment.jpg");
$mail->addattachment ("Attachment.zip");
Set the Mail recipient's mailbox and name $mail->addaddress ("toname@gmail.com", "FirstName LastName"); Send messages in HTML format $mail->ishtml (TRUE); Send mail via Send///////According to the result of delivery if (! $mail->send ()) {echo "Mailer Error:".
$mail->errorinfo;
else {echo "message has been sent";}
2. Use 163 script to send mail
You only need to change the SMTP configuration and account password, 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;
Testing through in a local wampserver environment requires opening the PHP_OPENSSL extension.
The above mentioned is the entire content of this article, I hope you can enjoy.