700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 使用phpmailer发送邮件提示SMTP Error错误的解决办法

使用phpmailer发送邮件提示SMTP Error错误的解决办法

时间:2023-06-23 11:03:34

相关推荐

使用phpmailer发送邮件提示SMTP Error错误的解决办法

后端开发|php教程

phpmailer,php,提示

后端开发-php教程

之前做项目的时候做了一个用phpmailer发送邮件的功能《CI框架结合PHPmailer发送邮件》,昨天步署上线(刚开始用新浪云,嫌贵,换成阿里了),测试的时候,发送邮件却意外报错了……….

网站源码下载,ubuntu保持文件快捷,tomcat+不抛出异常,遇到反爬虫,php学习例子外包,武隆区一站式seo推广包含什么lzw

phpweb成品网站源码632套打包,vscode搜索全局,ubuntu aux,tomcat 去掉cmd,sqlite脚本参数,帝国cms 电商插件,php后端系统的前端框架,梦见巨型爬虫攻击人,301重定向 php,seo新手零基础入门seo黑帽,比较赚钱的网站源码,网页制作 图片切换,用户注册系统界面模板lzw

我擦,没上线的时候好好的,次次成功,刚开始我以为是smtp地址的问题(我用的163邮箱),后来改成了QQ邮箱,发现还是没有用,没办法,只好问度娘了,后来看着百度上的答案才明白除了google的smtp服务器收到请求”smtp”会接受,其他的服务器就像我用的163,QQ什么的必须要收到大写的 “smtp”请求才行……….emmmmm…..

资源收费源码,ubuntu终端是 还是,jdk8和tomcat匹配,爬虫还有啥虫,php怎么禁止直接访问,深度seo搜索lzw

然后我在class.phpmailer.php中,将

public function IsSMTP() { $this->Mailer = smtp; }//改成public function IsSMTP() { $this->Mailer = SMTP; }

然后将:

switch($this->Mailer) { case sendmail:return $this->SendmailSend($header, $body); case smtp:return $this->SmtpSend($header, $body); default:return $this->MailSend($header, $body);}//改成switch($this->Mailer) { case sendmail:return $this->SendmailSend($header, $body); case SMTP:return $this->SmtpSend($header, $body); default:return $this->MailSend($header, $body);}

我本来以为这样就可以了,重启Apache,再次测试一下,结果第一个错误是解决了,又出现了一个报错:

Could not instantiate mail function

?????

不知道你们有没有出现,我运气差,只好又求助度娘,终于找到原因:有的虚拟主机,或服务器,为了安全起见屏蔽了“fsockopen()函数”导致无法发送邮件。

下面说一下解决办法:

首先,在php.ini中去掉下面的两个分号

;extension=php_sockets.dll

;extension=php_openssl.dll

之前我用PHPmailer的时候已经去掉了,这里仅仅提示一下。

然后替换fsockopen函数

将class.smtp.php文件中fsockopen函数换成pfsockopen函数:

$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//fsockopen改为:$this->smtp_conn = @pfsockopen($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

这样设置完,我的已经可以成功发送邮件了,如果同样有这方面问题的,可以参考上面的例子试一下。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。