douxihui8270 2018-05-10 20:28
浏览 150
已采纳

504 PHP发送邮件时网关超时

I am getting 504 Gateway time-outs only when an email is being generated. I've checked php.ini and set max_execution_time to 300 as well as default_socket_timeout. Once I remove the SMTP function and the site can no longer send an email there are no 504's on actions that require an email to be sent. SMTP is configured properly as I've used the same configuration on the test site. There's clearly something in the production environment missing or misconfigured but I'm not sure where to look. If anyone has any insight I would be very grateful as I've spend the last few days searching for answers.

This is running on AWS and using Amazon SES to send emails. Both the Prod and Dev are their own instances.

SMTP settings: (like I said, this works on the test site)

add_action( 'phpmailer_init', 'send_smtp_email' );
function send_smtp_email( $phpmailer ) {
    $phpmailer->isSMTP();
    $phpmailer->Host       = 'host';
    $phpmailer->SMTPAuth   = true;
    $phpmailer->Port       = 25;
    $phpmailer->Username   = 'username';
    $phpmailer->Password   = 'password';
    $phpmailer->SMTPSecure = 'tls';
    $phpmailer->From       = 'info@website.com';
    $phpmailer->FromName   = 'Site Name';
    $phpmailer->SMTPDebug  = 1;
}
  • 写回答

1条回答 默认 最新

  • doulai1910 2018-05-11 21:20
    关注

    I figured out the issue. AWS throttles port 25 which results back as a 504 on production since there's heavy traffic there, which is why Dev was working. I changed the port to 587 where they do not throttle and it works fine now.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看