Ubuntu – How to configure sendmail properly with PHP on EC2 (no SES)

PHPsendmailUbuntu

I have been struggling with sendmail for couple of days with no luck. I am trying to setup relay host, after following the answers in this question

https://stackoverflow.com/questions/10359437/sendmail-how-to-configure-sendmail-on-ubuntu

I got 'DSN Service unavailable' in the log file. Now I am getting 'Connection refused by [127.0.0.1]'

What I am trying to do is sending emails from PHP application on the EC2 instance from another smtp server(smtp.mydomain.com) if that possible, what is the required configuration for sendmail and php.ini?

Thanks

Best Answer

DSN service unavailable sounds relay is not configured properly.

you can edit /etc/mail/sendmail.cf or /etc/sendmail.cf

And change

# "Smart" relay host (may be null)

DS<mailserver_hostname>

This mailserver_hostname should be resolved by your box, otherwise create host entry to point where that is supposed to go.

PS: Personal opinion i would use postfix with sasl relay:

echo “mail.test.com    no-reply@Test.com:PASSWORD” > /etc/postfix/saslpass
vi /etc/postfix/main.cf

relayhost = [mail.test.com]:587
smtp_sasl_auth_enable = yes
smtp_use_tls=yes
smtp_sasl_password_maps = hash:/etc/postfix/saslpass
smtp_sasl_security_options = noanonymous

Postmap main.cf / restart postfix

Additional:

Add hostname into your hostfile.. /etc/hosts As you are trying to do sasl relay you can rename your hostname from localhost to something else.

And please check this, Link

Related Topic