简体   繁体   English

504网关在PHP发送邮件时超时

[英]504 Gateway Time-Out When PHP Sends Mail

I am getting 504 Gateway time-outs only when an email is being generated. 仅在生成电子邮件时,我收到504网关超时。 I've checked php.ini and set max_execution_time to 300 as well as default_socket_timeout. 我检查了php.ini,并将max_execution_time设置为300以及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功能,并且该站点无法再发送电子邮件,就没有504要求发送电子邮件的操作。 SMTP is configured properly as I've used the same configuration on the test site. SMTP配置正确,因为我在测试站点上使用了相同的配置。 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. 它在AWS上运行,并使用Amazon SES发送电子邮件。 Both the Prod and Dev are their own instances. Prod和Dev都是它们自己的实例。

SMTP settings: (like I said, this works on the test site) SMTP设置:(如我所说,这在测试站点上有效)

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;
}

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. AWS会限制端口25,因为那里的流量很大,因此导致生产恢复为504,这就是Dev正在工作的原因。 I changed the port to 587 where they do not throttle and it works fine now. 我将端口更改为587,在该位置他们不油门,现在可以正常工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM