PHP Email example, send an email of course need a client mailbox, today This example is to use QQ free enterprise mailbox as email mail,
01
02include "phpmailer/class.phpmailer.php";
03function Send_mail ($frommail, $tomail, $subject, $body, $ccmail, $bccmail) {
04$mail = new Phpmailer ();
05$MAIL->ISSMTP ();
06$mail->smtpdebug;
07$mail->host = "smtp.qq.com";
08$mail->smtpauth = true;
09$mail->port = 25;
10$mail->username = "admin@51yip.com";
11$mail->password = "Hu Jintao";
12$mail->addreplyto ($frommail, ' Tankzhang ');
13$mail->addaddress ($tomail);
14$mail->setfrom ($frommail, ' Tankzhang ');
15$mail->ishtml (TRUE);
16$mail->subject = $subject;
17$mail->msghtml ($body);
18if (! $mail->send ())
19{
20echo "The message failed to send.
";
21echo "Error Reason:". $mail->errorinfo;
22exit;
23}else{
24echo "Success";
25}
26}
27?>
Call the top function to send the message:
1$result= send_mail ("admin@163.com", "12345@qq.com", "Test", "Test", "", "");
Note: If you do not have QQ free mailbox friends, you can go to the Tencent website to register a, and then add members and DNS, if there is no DNS server, add two MX records, such as the use of dnspod.