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

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The setup is like this (Ubuntu 9.10):



eth0:1 and are web apps which need to send emails to their users. points to and vice-versa (A/PTR). MX -> Google. Google handles all incoming mail. points to and vice-versa (A/PTR). MX -> Google. Google handles all incoming mail.


  1. Local delivery must be disabled (must deliver to MX specified server), so that the following works (note that there is no local user bob on the machine, but there is an existing bob email user):

    echo "Test" | mail -s "Test 6"

  2. I need to be able to specify from which IP/domain name the email is delivered when sending an email.

I fought with sendmail. With not much luck.

Here's some debug info:

sendmail -d0.12 -bt < /dev/null

Canonical name:
UUCP nodename: host

Sendmail always uses canonical name (taken from eth0). I've found no way for it to select one of the UUCP codenames. It uses it for sending email:

echo -e "To:\nSubject: Test\nTest\n" | sendmail -bm -t -v Connecting to [] via relay...
220 ESMTP Sendmail 8.14.3/8.14.3/Debian-9ubuntu1; Wed, 31 Mar 2010 16:33:55 +0200; (No UCE/UBE) logging access from: localhost(OK)-localhost []
>>> EHLO

I'm ok with other SMTP solutions. I've looked briefly at nbsmtp, msmtp and nullmailer but I'm not sure they can deal with disabling local delivery and selecting different domains when sending emails.

I also know about spoofing sender field by using mail -a "From: <>" but it seems to be a half-solution (mails are still sent from domain instead of proper, so PTR records are unused and there's more risk of being flagged as spam/spammer).

share|improve this question
Hi Paweł, I have the same problem as yours. Did you succeeded to solve it with sendmail? Can you post your solution? It would help me a lot. Thanks, Levi – user69240 Feb 2 '11 at 17:19

I do not know about sendmail, but with exim you specify routers and transports. Routers take the email from/to addresses and decide which transport to use. For (1), Just create smtp transports and no local transports. For (2), you can specify an interface option when you create a transport. A config file would be something like this (not a complete config file and not tested):

begin routers

 driver = dnslookup
 condition = ${eq{$sender_address_domain}{}} # 'from' domain is
 transport = example2_smtp

 driver = dnslookup
 condition = ${eq{$sender_address_domain}{}}
 transport = example3_smtp

begin transports

 driver = smtp
 interface =

 driver = smtp
 interface =
share|improve this answer
Seems to be what I want. So far I've assembled a semi-decent sendmail setup. I'll give it a try in the nearest future. – Paweł Gościcki Apr 2 '10 at 21:04

Did you try using the mailertable? Mapping

do.main    esmtp:do.main

should work and make sendmail use the MX-record (untested).

share|improve this answer

I have setup multiple postfix instances in the manner you describe to service outgoing mail for two namespaces. It is a fairly involved procedure (mine more so since I am also DKIMProxy signing) but a good starting point is:

I documented the whole thing (on RHEL 5.6) so I can provide more detail, so let me know if you're going this route - I can provide additional info.

The Exim approach posted by Dan looks cleaner - I stuck with postfix/DKIMProxy since I've used this approach in the past.


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.