Sendmail to local domain ignoring MX records
I have set up my domain to use google apps for its mail server. I have set up the appropriate MX entries in DNS. All outside mail to that domain works fine - it goes to my gmail box. The problem is when I am sending mail from from my localhost using sendmail (e.g. using the php mail() function). Mail to "email@example.com" will go to my local mailbox for user "me", instead of checking the MX record for example.com and going to my gmail box.
If I change my hostname from "example.com" to "foo.example.com", the mail get's sent, but then mail to outside servers gets rejected because they think it's coming from foo.example.com which doesn't have the specified sender account.
So I would prefer to keep the hostname correct (example.com), but get sendmail working.
I have had this working before, perhaps by fluke, but I cannot seem to get it to work anymore.
I have been on this for about a week. I've googled my brains out and read the sendmail manual right through.. but can't seem to figure out what is going on.
The solution that I'm looking for will still use sendmail to send out all email (i don't want to send through an external SMTP server), but will allow mail to domains hosted on my machine to follow the MX records defined in those domains.
Any and all help is appreciated.