Skip to content

Instantly share code, notes, and snippets.

Last active Aug 30, 2017
What would you like to do?
HOWTO: Setup mail forwarding with Sendmail in Ubuntu 10.04 LTS

Copyright (c) 2011, Michael de Silva ( Blog: ~ Twitter: @bsodmike

Fix: 'config error: mail loops back to me (MX problem?)'

To prevent receiving config error: mail loops back to me (MX problem?) errors, you need to add each virtualdomain.tld to the /etc/mail/local-host-names file and re-compile your sendmail config via make.

You have asked mail to a domain (e.g., to be forwarded to a specific host (in this case, by using an MX record, but the relay machine doesn't recognise itself as Add to /etc/mail/local-host-names [known as /etc/ prior to version 8.10] (if you are using FEATURE(`use_cw_file')) or add "Cw" to your configuration file.


Perform the following to enable email forwarding from the virtual domain virtualdomain.tld to another email address (in this example, There are no local accounts associated - the aliases file has been left untouched.

Note that the hostname of the system this was performed on is different to virtualdomain.tld; typically, this should be the case for you as well (that's the whole point of virtual hosts; default will be bound to whatever VPS provided access domain defined in hostname).


# Hosts with to allow relaying
virtualdomain.tld RELAY


Remove ", Addr=" clauses to receive from any interface. Do this with caution as this opens up your MTA to be abused by spammers if you're not careful. /etc/mail/access needs to be setup carefully to ensure it rejects any domains apart from your own.

dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp')dnl

Add the following

dnl # Define virtualusertable
FEATURE(`virtusertable', `hash /etc/mail/virtusertable')dnl

Create virtusertable and add


Perform make and /etc/init.d/sendmail reload to restart the daemon. You can debug the relaying action by watching the log file by doing tail -f /var/log/mail.log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment