The setup is like this (Ubuntu 9.10):
eth0: 1.1.1.1 name.isp.com
eth0:0 2.2.2.2 example2.com
eth0:1 3.3.3.3 example3.com
example2.com and example3.com are web apps which need to send emails to their users.
2.2.2.2 points to example2.com and vice-versa (A/PTR). MX - Google. Google handles all incoming mail.
3.3.3.3 points to example3.com and vice-versa (A/PTR). MX - Google. Google handles all incoming mail.
Requirements:
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"
[email protected]
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: name.isp.com
UUCP nodename: host
a.k.a.: example2.com
a.k.a.: example3.com
...
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:
[email protected]\nSubject: Test\nTest\n" | sendmail -bm -t -v
[email protected]... Connecting to [127.0.0.1] via relay...
220 name.isp.com 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 [127.0.0.1]
>>> EHLO name.isp.com
I'm ok with other SMTP solutions. I've looked briefly at nbsmtp, msmtp and nullmailer but I'm not sure thay 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: <
[email protected]>" but it seems to be a half-solution (mails are still sent from isp.com domain instead of proper example2.com, so PTR records are unused and there's more risk of being flagged as spam/spammer).