I. First DOWNLOAD Phpmailer
Https://github.com/chenlian2015/phpmailer.git
Two. In the downloaded directory,
class.phpmailer.php
class.smtp.php
Two copies of files to your project directory
Three. Use
CharSet = "GBK";//Set the message encoding, the default iso-8859-1, if the Chinese language must be set, otherwise garbled $mail->issmtp (); Set $mail->smtpdebug = 1 using the SMTP service; Enable the SMTP debugging feature//1 = errors and messages//2 = messages only $mail->smtpauth = true; Enable the SMTP authentication feature//$mail->smtpsecure = "SSL"; Security protocol, can be commented out $mail->host = ' smtp.126.com '; SMTP server $mail->port = 25; The port number of the SMTP server $mail->username = ' Write your 126 mailbox here '; SMTP server user name, PS: I hit the $mail->password = ' Write your password here '; SMTP server password $mail->setfrom (' Write here your 126 mailbox ', ' who '); $mail->addreplyto (' Write here what you want to send to the mailbox ', ' name '); $mail->subject = $subject; $mail->altbody = ' To view the message, please use an HTML compatible email viewer! '; Optional, comment out and test $mail->msghtml ($body); $address = $to; $mail->addaddress ($address, '); $mail->addattachment ("windows.pdf"); Attachment//$mail-&Gt AddAttachment ("Images/phpmailer_mini.gif"); Attachment if (! $mail->send ()) {echo ' Mailer Error: '. $mail->errorinfo; } else {echo "message sent! Congratulations, the Mail was sent successfully! "; }}postmail (' Write here what you want to send to the mailbox ', ' My subject ', ' Lala '); >