php mail function: legitimate mails marked as spam by gmail and hotmail

Your envelope adress doesnt match the from adress.
This is the main reason why mails are regarded as spam.

The background is: The envelope adress (in your case [email protected]) isn’t really visible to the user.
Its just used by mailservers to return error mails. Historically because they are more relevant to the admin than to the user.
However today its de-facto standard to set the envelope address to the same as the user address.
Spammers don’t really do that because they either don’t have the possibility to or they don’t want to recieve all the backbouncing error mails when sending spam.
Or they don’t want the exploited users with the trojan worm be aware of their evil-doing.

In php/sendmail this function is called the f parameter.
You can read all about that in the function documentation: http://php.net/manual/en/function.mail.php

Classes like phpmailer or libmail do this their selves and its probably the best idea to use one of theese because they have been tested, are well designed and react to changes in their developement!

The next thing you could do is to set the reverse-dns to the same domain that the sender adress is.
If you do this you are really, really trustworthy because the mail can be matched to a server and thus to a provbider/admin and could be easily blacklisted by spam networks.
So if you would spam with a correctly set up reverse dns you wouldnt do it long.
There is a built-in directive in arpa rulse that the set up of such an entry takes a while so it cant be made somehow danymically and exploited.

This is however rather advanced and there can only be one reverse dns entry per ip adress. So you can’t do it on a shared hosting environment.
You also have to contact your provider to set them up but you can google for all that stuff.

Sum up:

  • correct your envelope adress, that should be fine
  • if you can, set a reverse dns entry

PS: there are not really rules how and when to regard a mail as spam and the teqniques above have only proven to work in praxis but there is absolutely no guarantee. Every mail provider can do what he wants… (yahoo was one of theese candidates to do their very own thing and to annoy everybody with it in the past)

good luck

Leave a Comment