Ubuntu – sendmail on ubuntu not working correctly

email-serverPHPsendmailUbuntu

I am in the process of setting up a new server which runs Ubuntu on a LAMP stack.

I have installed sendmail but it doesnt seem to work.

This is my output in the error log:

Apr 16 13:46:51 ip-10-33-164-173 sm-mta[12939]: STARTTLS=client, relay=mail.imagine-publishing.co.uk., version=TLSv1/SSLv3, verify=FAIL, cipher=AES256-SHA, bits=256/256
Apr 16 13:46:51 ip-10-33-164-173 sm-mta[12939]: r3GDkeJG012937: to=<web@imagine-publishing.co.uk>, ctladdr=<www-data@ip-10-33-164-173.eu-west-1.compute.internal> (33/33), delay=00:00:11, xdelay=00:00:11, mailer=esmtp, pri=120967, relay=mail.imagine-publishing.co.uk. [86.28.80.249], dsn=5.6.0, stat=Data format error
Apr 16 13:46:51 ip-10-33-164-173 sm-mta[12939]: r3GDkeJG012937: r3GDkpJG012939: DSN: Data format error
Apr 16 13:46:51 ip-10-33-164-173 sm-mta[12939]: r3GDkpJG012939: to=<www-data@ip-10-33-164-173.eu-west-1.compute.internal>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30000, dsn=2.0.0, stat=Sent

That error was taken from /var/mail/www-data
(reason: 553 5.1.8 Sender address <www-data@ip-10-33-164-173.eu-west-1.compute.internal> domain does not exist)

Im a bit of a newbie when it comes to server admin stuff so any help would be appriciated!

Best Answer

Your sendmail uses invalid "this host email name". It is used by default as domain in sender addresses. Other mail server reject such sender address (domain without DNS records).

Set both envelope sender and header sender addresses in you php configuration/script. Set them to user@valid.domain.
http://php.net/manual/en/mail.configuration.php
http://php.net/manual/en/function.mail.php

Your sendmail should be fixed too.
Change "this host email name" to name with A or MX DNS record:
* change hostname as reported by hostname --fqdn
OR
* change it for sendmail only https://www.sendmail.com/sm/open_source/docs/m4/whoami.html

Related Topic