Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've a Ubuntu webserver with Sendmail as my MTA

Currently when i email outside my webserver's domain e.g. to something like gmail or any other email outside the domain it works perfectly. I don't want my sendmail daemon to recognize as a local address I want it to send to the same way any other email is sent.

There will never be a case were i will use the local users on the webserver to collect these emails for

So how can I disable local delivery?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

You can do that by removing your domain name from /etc/hosts file. You need to configure senmail to use your domain name ( when sending the emails instead of localhost.

edit /etc/mail/ add the following:



   dnl MAILER(cyrusv2)dnl

type m4 /etc/mail/ > /etc/mail/ then run /sbin/service sendmail restart

backup everything you edit before any change!

this solution is working fine with me!

share|improve this answer
With the server's fully-qualified domain name matching exactly to the mail destination's FQDN, one thing to be careful of is applications depending on resolving to localhost once the entry is removed from hosts, since A-record lookups to will start returning the address from DNS. – Shane Madden Mar 1 '11 at 17:55

Sendmail treats the "w" class as what domains it will attempt local delivery for. The default CentOS configuration includes these lines, for example:

# file containing names of hosts for which we receive email

This specifies "w" to include the name "localhost" and the contents of the file "/etc/mail/local-host-names". I suspect that you have "" in "/etc/mail/local-host-names", probably set up during the system installation.

You'll want to double-check this, as I don't have a sendmail test system to verify this on so I can't verify this here. Also, it may vary somewhat depending on your exact sendmail installation, which can vary some by distribution or OS.

share|improve this answer

You can do that by adding rules to ruleset 2. In you file add the following:

R$* < $=w . > $*          $#esmtp $@[MX server for] $: $1 < @ $2 > $3

Remember that the left and the right hand side of the rule are separated via tabs, so do not copy paste. Then build your from your, restart sendmail and test.

You can use the bestmx map if you do not want to hardcode the MX server name between the brackets.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.