views:

46

answers:

3

We have three domains hosted on one dedicated server each with its own dedicated IP.

Domain A - Has the server primary IP address (default server IP)
Domain B - Has its own IP address
Domain C - has its own IP address

If an email goes out from Domain B then it uses the Domain A IP address in outgoing and this makes emails from Domain B using PHP go straight to spam box of Gmail etc.

Is there any way to change the source IP depending on where the email originates from in PHP? What should we change to fix this?

A: 

You're not giving any details about your server setup so this can't really be answered. PHP can, however, use a SMTP server of your liking. The easiest way to set this up is a tool like PHPMailer.

If you can't change the IP you're sending from, you need to change domain B's MX record making Domain A (or its IP) the mail server for that domain. I'm pretty sure spam filters like Google mail look for the MX record only. Of course, you would have to have both E-Mail sending and receiving facilities on Domain A for this to work.

Pekka
A: 

PHP is usually set up to drop mail onto the localhost MTA, which will always send it on from its own bound IP address. So, no.

To reduce the chances of being marked as spam because your mail comes from an address that doesn't tie up with the DNS records (MX or fallback A) for a domain, add an SPF record to the DNS for all the domains saying that mail from the sending IP address is fine.

bobince
I added the SPF record with Domain B IP address but it still gets stuck in the spam folder in gmail!So are you sure there is no way to allow MTA to pick source IP depending on domain?
ToughPal
That would be up to the MTA, there's no way to touch that from PHP. However the MTAs I am familiar with do not have such a feature. Note that in any case changes you make to the DNS won't propagate to the rest of the Internet (including GMail) immediately.
bobince
+1  A: 

This is nothing to do with PHP.

No you can't spoof addresses in the way you suggest - but the reason that emails are being classified as spam is because you've only got Host A published in your SPF. Just add the others to the permitted senders list:

"v=spf1 a:hostA.example.com a:hostB.example.com a:hostC.example.com"

C.

symcbean