phpmailer 本土测试提示发送成功,可是邮箱内无法接收

WBOY
Release: 2016-06-13 12:57:55
Original
756 people have browsed it

phpmailer 本地测试提示发送成功,可是邮箱内无法接收
求各位大侠指点,

<br />
	<?php <br />
require_once('class.phpmailer.php');<br />
require_once("class.smtp.php"); <br />
$mail  = new PHPMailer(); <br />
<br />
$mail->CharSet    ="UTF-8";                 //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置为 UTF-8<br />
$mail->IsSMTP();                            // 设定使用SMTP服务<br />
$mail->SMTPAuth   = true;                   // 启用 SMTP 验证功能<br />
$mail->SMTPSecure = "ssl";                  // SMTP 安全协议<br />
$mail->Host       = "smtp.163.com";       // SMTP 服务器<br />
$mail->Port       = 465;                    // SMTP服务器的端口号<br />
$mail->Username   = "123456@163.com";  // SMTP服务器用户名<br />
$mail->Password   = "123456";        // SMTP服务器密码<br />
$mail->SetFrom('123456@163.com', '123456');    // 设置发件人地址和名称<br />
$mail->AddReplyTo("123456@163.com","123456"); <br />
                                            // 设置邮件回复人地址和名称<br />
$mail->Subject    = '';                     // 设置邮件标题<br />
$mail->AltBody    = "为了查看该邮件,请切换到支持 HTML 的邮件客户端"; <br />
                                            // 可选项,向下兼容考虑<br />
$mail->MsgHTML('<b>Hello, 简体,繁篦!!</b>');                         // 设置邮件内容<br />
$mail->AddAddress('123456@163.com', "123456");<br />
$mail->SMTPDebug=true ;<br />
//$mail->AddAttachment("images/phpmailer.gif"); // 附件 <br />
if(!$mail->Send()) {<br />
    echo "发送失败:" . $mail->ErrorInfo;<br />
} else {<br />
    echo "恭喜,邮件发送成功!";<br />
} <br />
?> <br />
Copy after login

------解决方案--------------------
$mail->Port       = 465;                    // SMTP服务器的端口号
为什么不用 25 端口呢?
------解决方案--------------------
注释掉这两句
$mail->SMTPSecure = "ssl";                  // SMTP 安全协议
$mail->Port       = 465;                    // SMTP服务器的端口号

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