winwebmail建的邮件,PHP 用SMTP发失败。 把你的代码贴出来看看还有你的mail主机的情况,ip?端口?等等 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这是我用到的代码,用126,163等等其他的邮箱发都没问题public function sentEmail($sub,$from,$to,$concent,$password) { require_once('class.phpmailer.php'); $mail = new PHPMailer(); //new一个PHPMailer对象出来 $concent = eregi_replace("[\]",'',$concent); //对邮件内容进行必要的过滤 $mail->CharSet ="UTF-8";//设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码 $mail->IsSMTP(); // 设定使用SMTP服务 $mail->SMTPDebug = 1; // 启用SMTP调试功能 // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // 启用 SMTP 验证功能 $mail->SMTPSecure = "ssl"; // 安全协议 $str=explode("@",$from); $str1=$str[0]; $str2=$str[1]; $mail->Host = 'SMTP.'.$str2; // SMTP 服务器 $mail->Port = 465; // SMTP服务器的端口号 $mail->Username = $from; // SMTP服务器用户名 $mail->Password = $password; // SMTP服务器密码 $mail->SetFrom($from, $str1); $mail->Subject = $sub; $mail->MsgHTML($concent); $mail->AddAddress($to, ""); sleep(5); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo."请稍后再发!"; die(); } else { } } winwebmail系统设置接入方式:http/smtp/pop3,imap4SMTP服务 端口:25 绑定:ALL IPSMTP加密传输服务(SSL)POP3服务 端口:110 绑定:ALL IP收发规则: 启用SMTP发信认证功能防护:启用SMTP域名验证功能 $mail->SMTPSecure = "ssl"; // 安全协议$str=explode("@",$from); $str1=$str[0]; $str2=$str[1]; $mail->Host = 'SMTP.'.$str2; // SMTP 服务器 $mail->Port = 465; // SMTP服务器的端口号----------------------------------------------------1.你自己的smtp服务器的域名是不是类似这样: smtp.xxx.xxx?2.你自己的smtp服务器是否开启了ssl?3.你smtp服务器的端口是否是465? 那你修改一下端口:$mail->Port = 25; // SMTP服务器的端口号还有:$mail->Host = 'SMTP.'.$str2; // SMTP 服务器后面打印一下看看是不是你的smtp服务器的域名?echo $mail->Host; 改为25的话,返回的是SMTP -> ERROR: Failed to connect to server:(0)我的写法,就像这样:$from="[email protected]";$mail->SMTPSecure = "ssl"; // 安全协议$str=explode("@",$from); $str1=$str[0]; $str2=$str[1];打echo $mail->Host;出来是SMTP.chamatek.com都没有问题。 郁闷,winwebmail会有什么特别的地方吗?? 我在本机telnet SMTP.chamatek.com 25是可以连接的那你检查一下你调用函数的代码还有你的用户名和密码是不是正确 $mail->SMTPSecure = "ssl"; // 安全协议你把这句注释掉试试 我不知道你怎么调用的,我测试了一下是可以的,密码是我乱写的,所以显示验证错误:$from="[email protected]";$to='[email protected]';$sub='test subject';$con='test content';sentEmail($sub,$from,$to,$con,'123456');debug错误如下:SMTP -> ERROR: Password not accepted from server: 535 authentication failed.SMTP -> ERROR: RSET failed: 220 OKSMTP -> ERROR: RCPT not accepted from server: 550 Local user only or Authentication mechanismSMTP -> ERROR: RSET failed: 220 OK所以连接smtp服务器应该是没有什么问题的 麻烦你用一下我的帐号试一下可行不[email protected]密码:aaaaaa 找到一些问题,你的smtp服务器验证的用户名不是邮箱地址,比如[email protected],用户名是server你把$mail->Username = $from; // SMTP服务器用户名改成$mail->Username = $str1; // SMTP服务器用户名另外,我的phpmailer是1.73,没有SetFrom()和MsgHTML()这2个方法,所以我注释掉了,debug的结果是:SMTP -> ERROR: MAIL not accepted from server: 506 failed MAIL FROM verification with the authentication data.SMTP -> ERROR: RSET failed: 220 OK也就是from有错误不过你现在的问题是连接到smtp主机都有错误,看来是运行发送邮件的php代码的电脑不能连接smtp主机 我的代码和WINWEBMAIL是在同一台服务器上运行的$mail->Username = $from;这个没错的,是源邮箱地址WINWEBMAIL究竟能不能用PHP 去发的,好像网上都没答案。 我按照phpmailer1.73的格式发送成功了,代码如下:function sentEmail($sub,$from,$to,$concent,$password){ require_once('路径\class.phpmailer.php');//我的phpmailer路径,这里省略 $mail = new PHPMailer(); //new一个PHPMailer对象出来 $concent = eregi_replace("[\]",'',$concent); //对邮件内容进行必要的过滤 $mail->CharSet ="UTF-8";//设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码 $mail->IsSMTP(); // 设定使用SMTP服务 $mail->SMTPDebug = 1; // 启用SMTP调试功能 // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // 启用 SMTP 验证功能 $mail->SMTPSecure = "ssl"; // 安全协议 $str=explode("@",$from); $str1=$str[0]; $str2=$str[1]; $mail->Host = 'SMTP.'.$str2; // SMTP 服务器 $mail->Port = 25; // SMTP服务器的端口号 $mail->Username = $str1; // SMTP服务器用户名 $mail->Password = $password; // SMTP服务器密码 $mail->From=$from; $mail->Subject = $sub; $mail->Body=$concent; $mail->AddAddress($to, ""); sleep(5); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo."请稍后再发!"; die(); } else { } }$from="[email protected]";$to='[email protected]';//我的邮箱,这里用xxx代替$sub='test subject';$con='test content';sentEmail($sub,$from,$to,$con,'aaaaaa'); 应该不是代码的问题的了,因为我用其他的邮箱作为源邮箱发都没问题的,问题可能出在WINWEBMAIL设置上,暂时找不到。郁闷。 ===你用[email protected]发送能成功?? 兄弟,能发你这例的代码给我不??phpmailer也一起发来邮箱:[email protected]感谢呀!!! 请问 RTApiReqGetRow(),RTApiReqOpen()是什么函数? PHP 比较两个中文字符为何总是不对?? 小弟求教:什么是封装,怎么写 构架服务器问题 传值问题,有代码! php 定时器 怎么做??? 有个问题求大神解释 大家好啊,问一下,怎么用php实现。。。。。。 求助,有没有人懂这段代码,如何提交数据? 如何计算页面运行时间 【高手请近】PHP 【global引用传递】 和 【static 静态变量】 不起作用 求助,session的问题
public function sentEmail($sub,$from,$to,$concent,$password)
{ require_once('class.phpmailer.php');
$mail = new PHPMailer(); //new一个PHPMailer对象出来
$concent = eregi_replace("[\]",'',$concent); //对邮件内容进行必要的过滤
$mail->CharSet ="UTF-8";//设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
$mail->IsSMTP(); // 设定使用SMTP服务
$mail->SMTPDebug = 1; // 启用SMTP调试功能
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // 启用 SMTP 验证功能
$mail->SMTPSecure = "ssl"; // 安全协议
$str=explode("@",$from);
$str1=$str[0];
$str2=$str[1];
$mail->Host = 'SMTP.'.$str2; // SMTP 服务器
$mail->Port = 465; // SMTP服务器的端口号
$mail->Username = $from; // SMTP服务器用户名
$mail->Password = $password; // SMTP服务器密码
$mail->SetFrom($from, $str1);
$mail->Subject = $sub; $mail->MsgHTML($concent);
$mail->AddAddress($to, "");
sleep(5);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo."请稍后再发!";
die();
} else { }
}
SMTP加密传输服务(SSL)POP3服务 端口:110 绑定:ALL IP
收发规则: 启用SMTP发信认证功能防护:启用SMTP域名验证功能
$str=explode("@",$from);
$str1=$str[0];
$str2=$str[1];
$mail->Host = 'SMTP.'.$str2; // SMTP 服务器
$mail->Port = 465; // SMTP服务器的端口号
----------------------------------------------------
1.你自己的smtp服务器的域名是不是类似这样: smtp.xxx.xxx?
2.你自己的smtp服务器是否开启了ssl?
3.你smtp服务器的端口是否是465?
$mail->Port = 25; // SMTP服务器的端口号
还有:
$mail->Host = 'SMTP.'.$str2; // SMTP 服务器
后面打印一下看看是不是你的smtp服务器的域名?
echo $mail->Host;
$from="[email protected]";
$mail->SMTPSecure = "ssl"; // 安全协议
$str=explode("@",$from);
$str1=$str[0];
$str2=$str[1];
打echo $mail->Host;出来是SMTP.chamatek.com
都没有问题。
是可以连接的
那你检查一下你调用函数的代码
还有你的用户名和密码是不是正确
你把这句注释掉试试
$from="[email protected]";
$to='[email protected]';
$sub='test subject';
$con='test content';
sentEmail($sub,$from,$to,$con,'123456');debug错误如下:
SMTP -> ERROR: Password not accepted from server: 535 authentication failed.SMTP -> ERROR: RSET failed: 220 OKSMTP -> ERROR: RCPT not accepted from server: 550 Local user only or Authentication mechanismSMTP -> ERROR: RSET failed: 220 OK
所以连接smtp服务器应该是没有什么问题的
你把
$mail->Username = $from; // SMTP服务器用户名
改成
$mail->Username = $str1; // SMTP服务器用户名另外,我的phpmailer是1.73,没有SetFrom()和MsgHTML()这2个方法,所以我注释掉了,debug的结果是:
SMTP -> ERROR: MAIL not accepted from server: 506 failed MAIL FROM verification with the authentication data.SMTP -> ERROR: RSET failed: 220 OK也就是from有错误
不过你现在的问题是连接到smtp主机都有错误,看来是运行发送邮件的php代码的电脑不能连接smtp主机
我按照phpmailer1.73的格式发送成功了,代码如下:
function sentEmail($sub,$from,$to,$concent,$password)
{ require_once('路径\class.phpmailer.php');//我的phpmailer路径,这里省略
$mail = new PHPMailer(); //new一个PHPMailer对象出来
$concent = eregi_replace("[\]",'',$concent); //对邮件内容进行必要的过滤
$mail->CharSet ="UTF-8";//设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
$mail->IsSMTP(); // 设定使用SMTP服务
$mail->SMTPDebug = 1; // 启用SMTP调试功能
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // 启用 SMTP 验证功能
$mail->SMTPSecure = "ssl"; // 安全协议
$str=explode("@",$from);
$str1=$str[0];
$str2=$str[1];
$mail->Host = 'SMTP.'.$str2; // SMTP 服务器
$mail->Port = 25; // SMTP服务器的端口号
$mail->Username = $str1; // SMTP服务器用户名
$mail->Password = $password; // SMTP服务器密码
$mail->From=$from;
$mail->Subject = $sub; $mail->Body=$concent;
$mail->AddAddress($to, "");
sleep(5);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo."请稍后再发!";
die();
} else { }
}
$from="[email protected]";
$to='[email protected]';//我的邮箱,这里用xxx代替
$sub='test subject';
$con='test content';
sentEmail($sub,$from,$to,$con,'aaaaaa');
你用[email protected]发送能成功??
兄弟,能发你这例的代码给我不??phpmailer也一起发来邮箱:[email protected]感谢呀!!!