phpmailer发送邮件失败
来源:互联网 发布:烈焰遮天全套源码 编辑:程序博客网 时间:2024/04/29 06:32
在用phpmailer发送邮件时,本地都是好的,到服务器上就不行了,提示发送成功,但受不到邮件,firebug查看提示连接不上邮件服务器。在网上找了很久,最多的说法是这样:
更改phpmailer的class.smtp.php文件:
$this->smtp_conn = @fsockopen( $host, // the host of the server $port, // the port to use $errno, // error number if any $errstr, // error message if any $tval); // give up after ? secs
改为:
$this->smtp_conn = @stream_socket_client( $host.':'.$port, // the host of the server $errno, // error number if any $errstr, // error message if any $tval); // give up after ? secs
PHP版本应高于5.0,因为较早版本没有stream_socket_client函数。
按照上面改了,还是不行,然后对phpmailer一步步跟踪,发现问题还是出在连接163邮件服务器这里,在测试服务器上运行也正常,然后就将测试环境和生产环境比较,发现唯一的区别就是测试服务器是用域名访问的,而生产环境是用IP地址访问的,改成域名访问就正常了,至于为什么IP地址就不行,这就不知道了。反复测试后发现,生产环境的域名解析有点问题,有时会自动将URL中的域名转换IP地址。
总结一下邮件发送失败的几种原因:
1、SSL连接,有些邮件不需要SSL,如163,;有些需要,如gmail;
2、端口,163邮箱的端口是25,具体端口号应和你使用的邮箱一致;
3、fsockopen函数,按照上面方法改成stream_socket_client;
4、URL中的地址是域名还是IP地址,一定要是域名。
0 0
- phpmailer发送邮件失败
- linux phpmailer发送邮件失败
- linux phpmailer发送邮件失败
- PHPMailer发送邮件失败:SMTP connect failed
- PHPMailer发送邮件失败:SMTP connect failed
- centos使用phpmailer发送邮件失败的解决办法
- Linux服务器下PHPMailer发送邮件失败问题的解决
- 用 phpmailer 发送邮件
- PHP发送邮件---phpmailer
- PHPMailer发送邮件
- 使用PHPMailer发送邮件
- PHPMailer发送邮件
- 使用 PHPMailer 发送邮件
- 使用phpMailer发送邮件
- 【PHP邮件发送】PHPMailer
- PHPmailer发送邮件
- PHPMailer 发送邮件
- PHPMailer发送邮件
- 字符串的删除,插入,取串
- IOS从零开始之_objective-c初探中
- win7 iis6 配置如何让局域网内其它用户访问
- linux常用命令大全
- C++中this指针的小结
- phpmailer发送邮件失败
- 进程和cpu的相关知识和简单调优方案
- 2014年12月22日---28日(共23小时,剩3993小时,2014年共进行了775小时,汗颜)
- 黑马程序员 数组概要
- gsoap生成客户端程序,调用接口时出现 Error 200 fault: SOAP-ENV:Client [no subcode] 修改方法
- 剪花布条
- Polynomial Curve Fitting
- .NET Framework、C#、CLR和Visual Studo之间的版本关系
- 正则引擎对比