Friday, July 27, 2018

email - 504 Gateway Time-out Error on 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:





$message = $_POST['message'];

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

$subject="subject example";

$message = "



HTML email


message


$message




";


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

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


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




Has anyone ever experienced this problem?

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...