mx record server sending email back to webserver when webserver configured to use mx server to send

coderodour asked:

I have my webserver running a webmail client. I have this webmail client configured to use a seperate standalone mail server to send emails. I can send email from this webmail to gmail successfully.

However, upon trying to send email to an address on my own domain, I can see that I connect to the standalone server to send the email as the logs state:

Nov 12 12:47:46 mx dovecot: imap(sender@myowndomain.com): Disconnected: Logged out in=291 out=2751
Nov 12 12:48:46 mx dovecot: imap-login: Login: user=<sender@myowndomain.com>, method=PLAIN, rip=192.168.1.11, lip=192.168.1.12, mpid=19294, TLS, session=<6pT3wzxd4QrAqAoM>
Nov 12 12:48:46 mx dovecot: imap(sender@myowndomain.com): Disconnected: Logged out in=291 out=2751

But instead of the mx server itself receiving the email like it does for incoming email from other domains, i.e gmail etc., the email seems to be received at the web server where the mail log displays:

Nov 12 12:27:12 myservername postfix/pickup[29249]: 3210A1020814: uid=56 from=<sender@mydomain.com>
Nov 12 12:27:12 myservername postfix/cleanup[29254]: 3210A1020814: message-id=<5c688f30a84ffe77a3dr1f2adacd06bb@mydomain.com>
Nov 12 12:27:12 myservername postfix/qmgr[29250]: 3210A1020814: from=<sender@mydomain.com>, size=532, nrcpt=1 (queue active)
Nov 12 12:27:12 myservername postfix/local[29256]: 3210A1020814: to=<sender@mydomain.com>, relay=local, delay=0.09, delays=0.06/0/0/0.03, dsn=5.1.1, status=bounced (unknown user: "sender")
Nov 12 12:27:12 myservername postfix/cleanup[29254]: 3F1291020816: message-id=<20171112172712.3F1291020816@mydomain.com>
Nov 12 12:27:12 myservername postfix/bounce[29257]: 3210A1020814: sender non-delivery notification: 3F1291020816
Nov 12 12:27:12 myservername postfix/qmgr[29250]: 3F1291020816: from=<>, size=2288, nrcpt=1 (queue active)
Nov 12 12:27:12 myservername postfix/qmgr[29250]: 3210A1020814: removed
Nov 12 12:27:12 myservername postfix/local[29256]: 3F1291020816: to=<sender@mydomain.com>, relay=local, delay=0.05, delays=0.03/0/0/0.03, dsn=5.1.1, status=bounced (unknown user: "sender")
Nov 12 12:27:12 myservername postfix/qmgr[29250]: 3F1291020816: removed

How can I get the standalone mail server for which my mx record is configured to send the email my webmail server mail client sends through it to itself, rather than back to the webserver?

My answer:


Your webserver’s hostname matches exactly your naked domain name. This is not recommended, as it causes a variety of problems including misrouted mail.

To resolve the problem, rename the webserver. On that end-of-life server, you’ll have to manually edit /etc/hostname and then restart any affected services (though you can just reboot to be sure).


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.