Right now I am sending emails using the php mail() function. I am setting the From:
header to an address corresponding to the hostname and also reverse-dns of the server sending the email like this:
$header = 'From: Foo <[email protected]>' . "\r\n" .
'Reply-To: [email protected]' ;
$x = mail($to,$subject,$body,$header);
This works fine so var, every email gets through with all providers I tested.
The hostname is just something long and generic from my isp that supplies the root server.
I know that I can have the From: -header corresponding to my domain if I change the hostname (either system or in sendmail) and set up reverse dns accordintly.
However hostname to the same domain as a website runs on can cause problems in apache (like delivering the default vhost and not the domain specific).
I know that this all can be handled, however I would like not to have to manage mailserver and so on and thoughta bout using Amazon Simple Email Service
I set it up and everything, but emails keep getting marked as spam by Gmail.
I was surprised, because the reverse dns and spf policies correspond to the envelope adresses. However gmail seems to particuarly strict when evaulating the From: -header.
So I added SPF and SenderID records to my DNS
(I read up on that and added them using a wizard tool, from my understanding they should be correct. maby i have an error in here?)
This is an example of an email sent by amazon
And this is the output of dig -t txt mydomain.com
;; ANSWER SECTION:
mydomain.com. 1800 IN TXT "spf2.0/pra include:amazonses.com include:_spf.google.com ip4:1.2.3.4 ?all"
mydomain.com. 1800 IN TXT "v=spf1 include:amazonses.com include:_spf.google.com ip4:1.2.3.4 ?all"
I already allowed several dails for changes to propagate, but gmail still keeps marking my emails as spam.
So lets sum it up:
The From: -header tld does not correspond with the envelope domain, but the envelope domain does correspond with reverse dns and hostname of sending server (this is all amazon).
There are SPF and SenderId records set up that correspond to the From: -header.
Gmail keeps marking mail as spam.
Can anyone point me in the right direction?
Well, I don't know about anyone else, but Amazon's SES is in my spam filters as a persistent and unrepentent source of spam, and the service does nothing to help me to identify which users of the service are legit and which ones aren't. Not saying that's why gmail's calling a spade a spade, but it probably isn't helping.
SPF records aren't the only factor that is used when determining a message is spam. Gmail for example looks at DomainKeys / DKIM. See http://mailchimp.com/about/authentication/ for more information on the different email services and the different authentication techniques they use.
Looking at the headers in your email, SPF passed fine.
So you may want to look at implementing DomainKeys / DKIM for your emails. In Gmail, this would show a "Signed by" line in the details of the header.
Further to that, the content of the email also would have an impact. Doesn't matter whether Gmail believes the email is a genuine email, it may still flag your email as spam based on user feedback, content and other factors.
I have found all email originating from Amazon's EC2 IP ranges to be weighted heavily as Spam by most recipients, even with Reverse DNS and other anti-spam settings. I relay through external servers for anything important because of this. It is a major drawback to AWS.