VPS侦探论坛

 找回密码
 注册
查看: 4977|回复: 8

lnmp1.4 使用 phpmailer 发邮件 不是超时就是 502无响应

[复制链接]
发表于 2017-6-15 13:03:20 | 显示全部楼层 |阅读模式

军哥,在本地 phpstudy  nginx+php 都可以。上传到服务器就会报错。502?phpmailer 是从官网最小化安装的。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-6-15 14:06:47 | 显示全部楼层


开php-fpm慢日志和错误日志看一下
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2017-6-15 15:05:00 | 显示全部楼层

原帖由 licess 于 2017-6-15 14:06 发表
开php-fpm慢日志和错误日志看一下


php-fpm 日志
[15-Jun-2017 14:57:39] WARNING: [pool www] child 28550, script '/home/wwwroot/rainknowfirst/phpmailer/index.php' (request: "GET /phpmailer/index.php") executing too slow (122.529232 sec), logging
[15-Jun-2017 14:57:39] NOTICE: child 28550 stopped for tracing
[15-Jun-2017 14:57:39] NOTICE: about to trace 28550
[15-Jun-2017 14:57:39] NOTICE: finished trace of 28550
[15-Jun-2017 14:58:13] WARNING: [pool www] child 28550, script '/home/wwwroot/rainknowfirst/phpmailer/index.php' (request: "GET /phpmailer/index.php") execution timed out (155.863062 sec), terminating
[15-Jun-2017 14:58:13] WARNING: [pool www] child 28550 exited on signal 15 (SIGTERM) after 166.671172 seconds from start
[15-Jun-2017 14:58:13] NOTICE: [pool www] child 28553 started

慢日志:
[15-Jun-2017 14:57:39]  [pool www] pid 28550
script_filename = /home/wwwroot/rainknowfirst/phpmailer/index.php
[0x00007f4b8e572620] stream_socket_client() /home/wwwroot/rainknowfirst/phpmailer/class.smtp.php:294
[0x00007f4b8e571288] connect() /home/wwwroot/rainknowfirst/phpmailer/class.phpmailer.php:1660
[0x00007f4b8e570208] smtpConnect() /home/wwwroot/rainknowfirst/phpmailer/class.phpmailer.php:1540
[0x00007f4b8e56fcb0] smtpSend() /home/wwwroot/rainknowfirst/phpmailer/class.phpmailer.php:1335
[0x00007f4b8e56faa8] postSend() /home/wwwroot/rainknowfirst/phpmailer/class.phpmailer.php:1213
[0x00007f4b8e56f628] send() /home/wwwroot/rainknowfirst/phpmailer/index.php:32

好像是说 stream_socket_client() 这个函数连不上 smtp 服务器。默认php.ini 里的 disable_functions 里有这个函数。
我从里面删除后,重启 php-fpm 测试还是不行?看到一篇文章好像很符合我的情况  http://www.linuxdiyf.com/linux/26343.html
可是lnmp1.4下找不到相应的目录。军哥能帮忙看看吗?还有用官方 stream_socket_client() 例子试了,这个函数可以正常工作。但是连接 smtp 就是不行。

[ 本帖最后由 linda89757 于 2017-6-15 17:14 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-6-16 09:22:10 | 显示全部楼层

回复 3# 的帖子




1.4下composer安装了个phpmailer测试发邮件没有问题

安装包src目录下自己解压对应版本的php
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2017-6-16 11:39:42 | 显示全部楼层

原帖由 licess 于 2017-6-16 09:22 发表
1.4下composer安装了个phpmailer测试发邮件没有问题

安装包src目录下自己解压对应版本的php

军哥有没有试试从官方(https://github.com/PHPMailer/PHPMailer)那里下载上传安装。用最小化安装(就是下载 class.smtp.php 和 class.phpmailer.php 及 PHPMailerAutoload.php 和 demo),我用 composer 试了还是不行,502 .在 centos 7.2 64bit 上重新安装,(之前是 centos6.8 64bit )lnmp1.4 还是不行。还提示502 Bad Gateway。我最终放弃了 lnmp1.4.不知道是什么原因?但愿以后的版本能修好这个bug吧。

[ 本帖最后由 linda89757 于 2017-6-16 16:41 编辑 ]

军哥运维代购:http://shop63846532.taobao.com/

发表于 2017-6-16 18:15:29 | 显示全部楼层

回复 5# 的帖子


新装lnmp 1.4 环境,composer和单独只下载PHPMailerAutoload.php、class.smtp.php、class.phpmailer.php 自己写的测试脚本,使用qq smtp发送均没有任何问题
这个不是lnmp 1.4的问题,建议开debug信息,换个smtp服务器及账号密码试试
 楼主| 发表于 2017-6-16 20:40:37 | 显示全部楼层

原帖由 licess 于 2017-6-16 18:15 发表
新装lnmp 1.4 环境,composer和单独只下载PHPMailerAutoload.php、class.smtp.php、class.phpmailer.php 自己写的测试脚本,使用qq smtp发送均没有任何问题
这个不是lnmp 1.4的问题,建议开debug信息,换个smtp服务器及账号 ...

忘了给军哥说了,我用的是阿里云,默认25端口被封。防垃圾邮件。错怪军哥了。另,465端口没封,不过要使用得要证书,但不会弄,军哥有教程吗?

[ 本帖最后由 linda89757 于 2017-6-16 22:17 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-6-17 08:59:27 | 显示全部楼层

回复 7# 的帖子


连smtp不需要什么证书,只要phpmailer填写对接口和tls 或 ssl 不就行
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2017-6-18 09:37:27 | 显示全部楼层


原帖由 licess 于 2017-6-17 08:59 发表
连smtp不需要什么证书,只要phpmailer填写对接口和tls 或 ssl 不就行

终于弄好了,军哥是对的。谢谢军哥!!!
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-25 23:17 , Processed in 0.029348 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表