An example of PHP using QQ free email to send mail

Source: Internet
Author: User
Tags 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,

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.

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.