php使用smtp发送邮件报错Error: Cannot connenct to relay host smtp.163.com Error: ()解决方法
2017-02-19 14:17
941 查看
在使用smtp发送邮件时报错Error: Cannot connenct to relay host smtp.163.com Error: ()
解决方法如下:
a.找到php.ini,查看两个地方,一个是allow_url_fopen,这个地方要设置成on;另一个地方是查disable_functions,如果后面出现了fsock,fsockopen,则需要把这两个函数去掉,重启apache,然后就可以正常发送邮件了。
b. 如果是使用阿里云免费版云虚拟主机的话,登录主机管理平台在【高级环境配置】选项找到PHP.ini设置选项将PHP函数fsockopen设置启用即可;
2.再检查发送人的账户密码事是否正确;
最后测试下果然正常了
附件:email.class.php下载地址:http://download.csdn.net/detail/leesin2011/9764391
解决方法如下:
<?php require_once "email.class.php"; $smtpserver = "smtp.163.com"; $smtpserverport =25; $smtpusermail = "test@163.com"; $smtpemailto = "xxxxxxxx@qq.com"; $smtpuser = "test"; //注此处是邮箱去掉@之后的名称包括@ $smtppass = "*******"; //此处不是邮箱的登录密码,而是客户端的授权码 $mailtitle = 'test mail'; $mailcontent = "<h1>just test!</h1>"; $mailtype = "HTML"; $smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass); $smtp->debug = true; $state = $smtp->sendmail($smtpemailto, $smtpusermail, $mailtitle, $mailcontent, $mailtype); ?>1.检查自己的服务器的环境配置是否开通fsockopen;
a.找到php.ini,查看两个地方,一个是allow_url_fopen,这个地方要设置成on;另一个地方是查disable_functions,如果后面出现了fsock,fsockopen,则需要把这两个函数去掉,重启apache,然后就可以正常发送邮件了。
b. 如果是使用阿里云免费版云虚拟主机的话,登录主机管理平台在【高级环境配置】选项找到PHP.ini设置选项将PHP函数fsockopen设置启用即可;
2.再检查发送人的账户密码事是否正确;
最后测试下果然正常了
附件:email.class.php下载地址:http://download.csdn.net/detail/leesin2011/9764391
相关文章推荐
- PHP使用SMTP发送邮件报错代码535问题解决
- php 使用phpmailer 发送邮件(附带中文乱码的解决方法)
- 解决使用JavaMail发送邮件报错javax.mail.MessagingException: 500 Error: bad syntax
- php发送邮件二种方法 php使用smtp发送邮件
- Wordpress无法发送邮件,基于插件“Contact Form 7”,修改class-phpmailer.php使用SMTP解决。
- 调试php没法使用smtp发送邮件的问题
- oracle11g新特性-安全性 发送邮件 报错ora-24247 解决方法
- [转]使用php mailer类调用远程SMTP服务器发送邮件Could not execute: /var/qmail/bin/sendmai
- 在PHP中使用Pear 的NetMail发送smtp邮件
- 使用cackPHP发送smtp邮件
- 在Asp.Net中使用SmtpMail发送邮件的方法
- 在PHP中使用Pear 的NetMail发送smtp邮件
- 使用PHP发送邮件的两种方法
- 使用Pear和php socket来实现通过smtp验证发送邮件
- 使用indy9不能发送邮件的解决方法
- PHP发送邮件乱码的具体解决方法
- 用utl_smtp发送邮件时的汉字解决方法
- 在PHP中使用Pear 的NetMail发送smtp邮件
- 在PHP中使用Pear 的NetMail发送smtp邮件
- Zimbra邮件系统安装与使用过程中各种报错与问题的详细解决方法