drsqpko5286 2018-05-10 09:19 采纳率: 0%
浏览 116

504 PHP Mail / EC2上的网关超时错误

I'm trying to send an email using php's mail() function.

It worked fine in my local environment(macos). In EC2(ubuntu 16.0.6 LTS), mail is sent but a 504 error occurs.

504 Gateway Time-out
nginx/1.10.3 (Ubuntu)

I checked these things:

  • php.ini : smtp_port 25
  • open SMTP port 25 (inbound, outbound on VPC and sequrity group)

And my php code:

<?php

$message = $_POST['message'];

$to = "sample@example.com";
$charset = 'UTF-8';

$subject="subject example";

$message = "
<html>
    <head>
    <title>HTML email</title>
    </head>
    <body>
        <p><b>message</b></p>
        <p>$message</p>
    </body>
</html>
";

// headers
$headers = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=UTF-8" . "
";
$headers .= 'From: <'sample@example.com'>' . "
";

mail($to, $subject, $message, $headers);
?>

I put this php in the action of the form tag.

Has anyone ever experienced this problem?

  • 写回答

1条回答 默认 最新

  • dongzhuo6137 2018-05-10 09:23
    关注

    You can increase maximum execution time in php.

    ini_set('max_execution_time', 300); //300 seconds = 5 minutes

    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题