Home > php教程 > php手册 > phpmailer邮件发送实例(163邮箱 126邮箱 yahoo邮箱)

phpmailer邮件发送实例(163邮箱 126邮箱 yahoo邮箱)

WBOY
Release: 2016-05-25 16:44:02
Original
1692 people have browsed it

phpmailer是一个非常优秀的php邮箱发送插件了,他可以几乎实现任何邮箱登录发送,下面我介绍163邮箱 126邮箱 yahoo邮箱的发送方法.

准备工作:我们必须注册一个邮箱(163邮箱 126邮箱  yahoo邮箱)随便一个

注意事项:这些邮箱必须是支持登录发送才可以,我们配置就一个地方不。

163邮箱 $mail->Host = "smtp.163.com";

126邮箱 $mail->Host = "smtp.126.com";

yahoo邮箱 $mail->Host = "smtp.mail.yahoo.com.cn";

其它的地方一样的写法,用户名密码你当然要写自己的,我下以163邮箱为实例,代码如下 :

<?php
require_once (&#39;../class.phpmailer.php&#39;);
$mail = new PHPMailer();
$body = "我终于发送邮件成功了!呵呵!<br/>";
//采用SMTP发送邮件
$mail->IsSMTP();
//邮件服务器
$mail->Host = "smtp.163.com";
$mail->SMTPDebug = 0;
//使用SMPT验证
$mail->SMTPAuth = true;
//SMTP验证的用户名称
$mail->Username = "********@163.com";
//SMTP验证的秘密
$mail->Password = "***";
//设置编码格式
$mail->CharSet = "utf-8";
//设置主题
$mail->Subject = "测试";
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
//设置发送者
$mail->SetFrom(&#39;****@163.com&#39;, &#39;test&#39;);
//采用html格式发送邮件
$mail->MsgHTML($body);
//接受者邮件名称
$mail->AddAddress("***@163.com", "test"); //发送邮件
if (!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}
?>
Copy after login

注意,红色地方就是根据你自己的需要修改.


本文地址:

转载随意,但请附上文章地址:-)

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template