views:

321

answers:

2

I have set up an AJAX contact form on a client's website.

The problem is that the email is not getting through to the client's inbox.

I set up the client with Google Apps (in the same way I did for myself).

I used the same contact form with my email address and it works. But with any email addresses on their domain it doesn't!

All members of the domain are receiving 'ordinary' emails.

What could be the difference that's stopping mail() emails getting through?


UPDATE

Ok so I managed to solve it. Turns out that using a CNAME to point the domain to the correct server wasn't enough for sendmail so I had to change it to an A record pointing directly to the server. Strange but true. Thanks for the help folks, you pointed me in the right direction :)

+2  A: 

It depends on the both settings on your server and the server on the receiving end.

hotmail for example requires the use of correctly configured SPF records.

many mail-receiving servers (including hotmail) require the email to originate from a Fully Qualified Domain Name. It is very possible that your e-mails send from PHP do not comply with this rule. (there is a good chance they originate from 'apache')
see hotmail self help and hotmail postmaster info

PHP's mail() function does not include a lot of headers with your mail, so you will need to supply them yourself.

The more hops your mail makes on it's way to it destination, the more likely it is to be tagged as spam. So it might be a better option not to use PHP's mail function and instead use a mail library that connects to an SMTP server just like your desktop mail application does.

All in all, I would place my bets on an external library: Pear::Mail (documentation)

You could also read: how do you make sure email you send programmatically is not automatically marked as spam

UPDATE
Failing the SenderId or SPF check can get your message dropped before it even hits the users inbox. The message will not end up in the users junk folder, it will go directly to /dev/null. I know this is at least true for hotmail and live mail. I see no reason for other hosts not to have implemented the same policy.

Jacco
I agree with this wholeheartedly, but why does it work for me and other clients using the same setup, but not this one client? It's very strange!
scrumpyjack
If you've once accepted/replied/send an email to this address, this would influence the filters on your receiving server.And not every server checks the SPF-record conformance.
Jacco
Are you saying that this message would get dropped before it even hits the user's account? So they would have no trace of it?That would be a mega FAIL for email if that's true!
scrumpyjack
No, SPF records are rubbish. Don't configure them at all, it will not help. It turns out that spammers use SPF records correctly more often than legitimate senders; I'm sure that Hotmail and all other providers ignore them or give them negative weight - I work for an email security vendor and we certainly do.
MarkR
Well, I use SPF and they nearly eliminated the number of spam messages claiming to be send FROM my domain. I've since been able to deliver my email directly to customers inboxes. So they can definitely help.
Jacco
Hotmail does not use SPF, but SenderId (RFC 4406); A SPF-derived standard. A correclt configured SPF-record is recognized and weighted.
Jacco
I have SenderID and SPF records set up and the mail is still not getting through from PHP's mail() function.I have to reiterate how there's *no difference* in the set up between this client's website and emails to the way my own website and emails are set up. And those work, with the same code.So there is logically no reason why this shouldn't be working
scrumpyjack
is _all_ header information the same? is your server blacklisted ?
Jacco
Yeah all header information is exactly the same, and the server isn't blacklisted
scrumpyjack
Well, something is different.. otherwise the receiving server could not be making the distinction
Jacco
A: 

I recommend using PHPMailer (including their SMTP) library instead. It is reliable compared to mail and allows you to create fully customized emails.

http://phpmailer.worxware.com/

dusoft
Again, I agree, but understanding WHY it's NOT working in this case is more useful to me than 'just making it work'
scrumpyjack
the mail function should work. Sending mails through a local sendmail is usually the best way to delivery them.
MarkR
i you agree, then use it instead of spending hours and hours asking at the forum why the unreliable mail() doesn't work for you on this particular machine.
dusoft
@dusoft that kind of comment doesn't help anyone! what's the point of coming on here to help solve problems if all you can do is throw blanket solutions at them that everyone else (including myself) has already thought of!
scrumpyjack
i am sorry if i offended you but trying to make mail() work is very unproductive - based on my experience. i am running a website that sends tens to hundreds of emails per day and if i was working with mail(), most of these emails would get undelivered. so, from the long time perspective i advise everyone to use proper SMTP libraries such PHPMailer. that's all.
dusoft