Home > Backend Development > PHP Tutorial > An example of using PHP to send emails using QQ free mailbox_PHP tutorial

An example of using PHP to send emails using QQ free mailbox_PHP tutorial

WBOY
Release: 2016-07-13 10:30:25
Original
907 people have browsed it

An example of sending emails with PHP. Of course, sending emails requires a client email. Today’s example uses QQ free corporate email as the email address for sending emails.

 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 = "******";

 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 "Failed to send email.

 ";

 21echo "Error reason: " . $mail->ErrorInfo;

 22exit;

 23}else{

 24echo "success";

 25}

 26}

 27?>

Call the above function to send email:

 1$result= send_mail("admin@163.com","12345@qq.com","test","test","","");

Note: If you don’t have a free QQ mailbox, you can register one on the Tencent website, and then add members and DNS. If there is no DNS server, add two mx records, such as using dnspod.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/765438.htmlTechArticleExample of sending emails with PHP. Of course, sending emails requires a client email. Today’s example is using QQ free corporate email As the email address for sending emails, 01 02include PHPMailer/class.phpm...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template