PHPMailer can be achieved convenient to send mail through php back-office functions.
1. To use a mail in the mailbox, the need for mailbox POP3 / SMTP service on:
To QQ mailbox, for example, the setting - open service accounts, the POP3 / SMTP service is turned on, the authorization code and note (to use the back).
2. Modify the php.ini file
The; extension = foregoing php_openssl.dll remove the semicolon.
3. Download PHPMailer package
Download link: https: //pan.baidu.com/s/1jX3kCAq8uQ69-Y91dsOWwg extraction code: i1vg
The downloaded package on your project, and then open email.php:
$ number = $ _REQUEST [ "number "]; // receiving transmitted value $ email = $ _REQUEST [ "email "]; // received value transmitted sendMail ($ email, "191 game", "game [191 ] your email verification code is: 191 Games "); // execution method, send a message" number the $,. " //% to -> destination mailbox, $ title -> title, $ content -> content, $ company -> signature function sendMail ($ to, $ title, $ Content, $ Company) { // this PHPMailer is downloaded from Github down before that project require '../PHPMailer/PHPMailer/PHPMailerAutoload.php'; new new PHPMailer mail = $; // send mail using smtp authentication $ mail-> isSMTP (); // this must be smtp authentication is needed to true $ mail-> = SMTPAUTH to true; // QQ mailbox smtp server address, here of course also be written other smtp server address $ mail-> Host = 'smtp.qq.com' ; // smtp login account here fill qq number string format to $ mail-> Username = '62 ****[email protected] ' ;
// This is previously obtained authorization code, a total of 16 mail- $> = Password 'mgpep ******* bfbe'; // Message Format $ mail-> Debugoutput = 'HTML'; $ mail-> the ContentType = 'text / HTML'; // message encoding $ mail -> the CharSet = 'UTF-. 8'; $ mail-> the setFrom (**** [email protected] '62 ', $ Company); // $ to a recipient's email address, if you want to send a one-time to multiple email addresses, you only need to call the following method multiple times to $ mail-> addAddress ($ to); // subject of the mail $ mail-> Subject = $ title; // the body of the message content mail- $> $ Content = Body; // use the send () method sends the message IF ($ mail-> send ()!) { echo 'succ'; return 'send failed:'. $ mail-> the ErrorInfo; } the else { return "transmission success"; } }
After calling the method to modify the data can be sent by mail