Centos – Disable local delivery in Sendmail

centossendmail

I am using Sendmail on a Centos server to send email for PHP scripts, but the problem is that mail is delivered to a local mailbox on the machine rather than what is specified in the MX records for the domain – which actually point to another machine I use for email.

I would like sendmail to not try and locally deliver mail for the domain the machine is setup for, is there a simple way to disable local delivery?

The domain is not in the local-host-names file.

I've already done lots of googling and I have looked at:

Sendmail Configuration to not deliver mail to local machine

Disable local delivery in Sendmail

But either there is no answer or it is not suitable.

I don't want to relay to another server, i just want it to send mail regardless of domain.

To provide an example:

I have two servers, one is the mail server at mail.example.com and a web server which is example.com, when I use the smtp service on the web server it currently routes mail to a local mailbox on example.com, but it should be going to mailboxes on mail.example.com

Output of sendmail -bt returns:

ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter  
> 3,0 info@example.com
canonify           input: info @ example . com
Canonify2          input: info 
Canonify2        returns: info 
canonify         returns: info 
parse              input: info 
Parse0             input: info 
Parse0           returns: info 
ParseLocal         input: info 
ParseLocal       returns: info 
Parse1             input: info 
Parse1           returns: $# local $: info
parse            returns: $# local $: info

Best Answer

What I did to disable local delivery. I'll be using the example.com domain.

Requirements:

  • example.com A entry pointing to IP address assigned to one of the eth interfaces.
  • /etc/hosts defining example.com assigned to the very same IP address as above
  • example.com MX records pointing to Google servers (ASPMX.L.GOOGLE.COM, etc)
  • default sendmail installation (mine was on Ubuntu)

Steps:

vim /etc/mail/sendmail.mc

at the end:

define(`MAIL_HUB', `example.com.')dnl
define(`LOCAL_RELAY', `example.com.')dnl

and then:

sendmailconfig (or /etc/mail/make depending on your distro)
service sendmail restart

testing:

echo -e "To: user@example.com\nSubject: Test\nTest\n" | sendmail -bm -t -v
echo -e "To: user\nSubject: Test\nTest\n" | sendmail -bm -t -v

You should see it connecting to the google server and then you should see your mail being delivered to your Google inbox.