PHP use QQ free mailbox to send mail instance

Source: Internet
Author: User
Tags echo message php email

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.