Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
230 views
in Technique[技术] by (71.8m points)

Sendmail service says it works but no email was sent (Nginx + EC2 + PHP form)

I spinned up a t3.medium EC2 instance on AWS to host a simple web application which contains a boostrapped php contact form. I configured nginx and php-fpm according to this guide: https://www.tecmint.com/connect-nginx-to-php-fpm/

Prior to configuring php as above, the php form couldn't work (it uses the php function mail()). After configuring as above, the form submits successfully. However, no email arrived.

After digging, I followed this tutorial to configure Sendmail with AWS Simple Email Service https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-sendmail.html

Everything was correctly configured and when I tested sendmail service via command line, sendmail says message is accepted for delivery but no email actually arrived

enter image description here

In the maillog, I see that the connection is timed out "delay=1+12:10:22, xdelay=00:00:00, mailer=relay, pri=3360503, relay=email-smtp.us-east-1.amazonaws.com., dsn=4.0.0, stat=Deferred: Connection timed out with email-smtp.us-east-1....amazon.com"

I contacted AWS and they told me my account is active and able to send email. I also tested sending mail from AWS and it worked.

For php-fpm, my config is as follows:

listen = /run/php-fpm/www.sock
listen.owner =nginx
listen.group = nginx
listen.mode = 0660

My nginx config in nginx/sites-enabled/website.config is:

index index.php index.html index.htm;
    location ~ .php$ {
       fastcgi_split_path_info ^(.+.php)(/.+)$;
       fastcgi_pass unix:/run/php-fpm/www.sock;
       fastcgi_index index.php;
       include fastcgi_params;
    }

The socket file is successfully created during runtime and php-fpm process is active.

I'm new to setting up mail server and honestly don't know what to do here. AWS won't help until I pay for support but I feel like it's not worth it because I'm so close to making it work. Would really appreciate some guidance.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...