Take the 2-minute tour ×
Server Fault is a question and answer site for professional 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. example.com to something like gmail or any other email outside the example.com domain it works perfectly. I don't want my sendmail daemon to recognize example.com as a local address I want it to send to example.com 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 example.com.

So how can I disable local delivery?

share|improve this question

3 Answers 3

up vote 2 down vote accepted
+25

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

edit /etc/mail/sendmail.mc add the following:

     MASQUERADE_AS(example.com)dnl
     FEATURE(masquerade_envelope)dnl
     FEATURE(masquerade_entire_domain)dnl
     MASQUERADE_DOMAIN(example.com)dnl

before:

   MAILER(smtp)dnl
   MAILER(procmail)dnl
   dnl MAILER(cyrusv2)dnl

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

backup everything you edit before any change!

this solution is working fine with me!

share|improve this answer
2  
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 example.com resolving to localhost once the entry is removed from hosts, since A-record lookups to example.com 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:

Cwlocalhost
# file containing names of hosts for which we receive email
Fw/etc/mail/local-host-names

This specifies "w" to include the name "localhost" and the contents of the file "/etc/mail/local-host-names". I suspect that you have "example.com" 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 sendmail.mc file add the following:

LOCAL_RULE_2
R$* < $=w . > $*          $#esmtp $@[MX server for example.com] $: $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 sendmail.cf from your sendmail.mc, 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

 
discard

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.