search
Homephp教程php手册PHP使用QQ免费邮箱发送邮件的一个例子

   PHP发邮件的例子,发邮件当然需要一个客户端邮箱,今天这个例子是使用QQ免费企业邮箱来做为发邮件的邮箱,

  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 "邮件发送失败.

  ";

  21echo "错误原因: " . $mail->ErrorInfo;

  22exit;

  23}else{

  24echo "success";

  25}

  26}

  27?>

  调用上边的函数来发送邮件:

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

  注:如果没有QQ免费邮箱的朋友,可以自己去腾讯网站注册一个,然后添加成员和DNS,如果没有DNS服务器的话,就添加二个mx记录,比如使用dnspod。

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools