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,
The code is as follows |
Copy Code |
<?php Include "phpmailer/class.phpmailer.php"; function Send_mail ($frommail, $tomail, $subject, $body, $ccmail, $bccmail) { $mail = new Phpmailer (); $mail->issmtp (); $mail->smtpdebug; $mail->host = "smtp.qq.com"; $mail->smtpauth = true; $mail->port = 25; $mail->username = "admin@51yip.com"; $mail->password = "Hu Jintao"; $mail->addreplyto ($frommail, ' Tankzhang '); $mail->addaddress ($tomail); $mail->setfrom ($frommail, ' Tankzhang '); $mail->ishtml (TRUE); $mail->subject = $subject; $mail->msghtml ($body); if (! $mail->send ()) { Echo message failed to send. <p> "; echo "Error Reason:". $mail->errorinfo; Exit }else{ echo "Success"; } } ?> |
Call the top function to send the message:
The code is as follows |
Copy Code |
$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.