PDA

View Full Version : Using Google Apps, sendmail doesn't work



amccarter
04-08-2007, 03:41 PM
I am using Google Apps to handle the email for my domain.

On the site, there is a simple contact form that uses the php mail() function. It works fine for any email address outside the domain. But if I set it to send the email to an address inside the domain, it goes to the local mailbox (ie: in Horde or Squirrelmail), instead of to the Google Apps mailbox.

All other mail sent to internal addresses go through the Google Apps mailbox just fine. Any idea why sendmail won't follow the rules?

For the record, here's the script:

$message = wordwrap($message,70);
$email_to = "me@mydomain.com";
$headers = "From: contact@mydomain.com";
$body = "Name: $name <$email_from>\nPhone: $phone\nMessage: $message"
mail($email_to, $subject, $body, $headers);

Like I said, if I change $email_to to some address that isn't on mydomain.com (like say, foo@bar.com), it sends the mail just fine. And actually, even sending it to me@mydomain.com, it works, but it only shows up on the local webmail inbox, not the Google Apps inbox, like it should.

WomenFly
04-08-2007, 05:40 PM
If all your email for mydomain.com is being handled by Google Apps then you can set up a redirect through "Email Domain Forwarders" in the Email Manager in cPanel. If it is a specific address you can use the "Forwarders" function.

amccarter
04-08-2007, 06:15 PM
What would I forward?

Forward all mail from me@mydomain.com to me@mydomain.com? sendmail seems to be ignoring the MX record.

tmchow
05-15-2007, 12:22 PM
Any luck with this?

I'm having the same problem it seems with my wordpress notifications as soon as I moved to Google Apps for my email and changed my MX record.

iigim
08-28-2007, 05:14 PM
http://forums.cpanel.net/showthread.php?t=70129&highlight=google+apps explain what has to be done in order to solve the problem of using Google Apps to send mail to the local domain from within PHP or other scripts that would normally works.

jInit
01-27-2009, 06:58 PM
I'm not on bluehost, but one solution is to edit /etc/mail/local-host-names if you have access.

open /etc/mail/local-host-names and comment out your domain name that you are using for Google Apps, then restart sendmail.

jInit