Linux: Send mail to external mail box from a server with that user’s hostname

linuxsendmail

I've got sendmail running on a linux box. Let's say the hostname of the box is bar.com. If I run the following command, I don't receive the email (which is hosted with a third party), presumably due to the hostname pointing to the local machine.

echo "Test Body" | mail -s "Test Subject" foo@bar.com

Is there any way to get this to work so that I can receive emails at my third party email address even though it has the same hostname? Do I have to change the hostname of this server (not preferred)?

It may be worth noting that I created a user "foo" on my machine and noticed that the mailbox for that account is empty.

I noticed these log entries, which may or may not be relevant:

Jun 28 01:09:48 bar sendmail[14338]: p5S59min014338: from=apache, size=80, class=0, nrcpts=1, msgid=<201106280509.p5S59min014338@bar.com>, relay=apache@localhost
Jun 28 01:09:48 bar sendmail[14339]: p5S59mIA014339: from=<apache@bar.com>, size=293, class=0, nrcpts=1, msgid=<201106280509.p5S59min014338@bar.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.$
Jun 28 01:09:48 bar sendmail[14338]: p5S59min014338: to=foo@bar.com, ctladdr=apache (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30080, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p5S59mIA$
Jun 28 01:09:48 bar sendmail[14340]: p5S59mIA014339: to=<foo@bar.com>, ctladdr=<apache@bar.com> (48/48), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30495, dsn=2.0.0, stat=Sent

Best Answer

With Flimzy's comment, I was able to get this working. It may not be the exact solution to my original question, but it is true that the server's hostname should be a subdomain.

What I did was changed the hostname to abc.bar.com:

(Fedora specific instructions)

For the existing session: hostname abc.bar.com

Permanently: edit /etc/sysconfig/network

Then service sendmail restart and voila!

Related Topic