How to avoid being spam
Hi all
As a contribution to Flabby Rabbits post on how to send an e-mail with PHP, I want to supply some information on how to make the e-mail safe, so that it will not be marked as Spam when received. I thought I'd post it here as a standalone-topic.
There are several rules the e-mail should meet.
If you use an MTA (Mail Transfer Agent / Mailserver) instead of sending the mail directly, it will be easier to meet the conditions.
[size=117:2csjqn4t][color=darkred:2csjqn4t][b:2csjqn4t]1) DNS stuff[/b:2csjqn4t][/color:2csjqn4t][/size:2csjqn4t]
[list:2csjqn4t]The most important thing is that the MTA of the recipient will trust you. If you are trusted, chances are very good you will not be marked as spam:
-> [b:2csjqn4t]the mail-from (sender email-address) should be an [color=red:2csjqn4t]existing domain[/color:2csjqn4t][/b:2csjqn4t], e.g.
From: yourname@[color=red:2csjqn4t]existingdomain.com[/color:2csjqn4t]
-> [b:2csjqn4t]the reverse DNS of your sending IP-Address should match the name of your MTA[/b:2csjqn4t]
(/etc/mailname on Debian).
You can check your reverse DNS by issuing the linux command
$ host <ip-address>.
In most cases, the ISP is responsible for the reverse DNS.
-> [b:2csjqn4t]set up an SPF record for your domain[/b:2csjqn4t] and see that it matches with your MTA
([url=http://www.devppl.com/forum/help-preventing-spam-add-a-spf-record-on-your-domain-vt9600.html:2csjqn4t]click here for more[/url:2csjqn4t]).
-> [b:2csjqn4t]do not send from a dynamic IP-Address.[/b:2csjqn4t]
Most of the dynamic IP-ranges are blacklisted, and if not, they sooner or later will be, due to your spammer-neighbors.
-> [b:2csjqn4t]make sure your IP-address is not blacklisted[/b:2csjqn4t]
(you will notice by the replies if it is).
-> [b:2csjqn4t]make sure your domain is not blacklisted[/b:2csjqn4t]
(you will notice by the replies if it is).[/list:u:2csjqn4t]
[size=117:2csjqn4t][color=darkred:2csjqn4t][b:2csjqn4t]2) Content[/b:2csjqn4t][/color:2csjqn4t][/size:2csjqn4t]
[list:2csjqn4t]-> [b:2csjqn4t]see that your sender-address does not begin with special characters[/b:2csjqn4t] like '_' or '-'.
This is a common spammer technique to be on the top of the list when sorted by name.
-> [b:2csjqn4t]avoid adverts or links to dubious pages.[/b:2csjqn4t]
Spam-filters like SpamAssassin add spam-points for links to blacklisted sights. Two links to blacklisted sights will suffice for the mail to have enough spampoints to be marked as spam.
My own SpamAssassin once marked an email of Yahoo as spam due to its heavily blacklisted advert-link.
-> [b:2csjqn4t]avoid certain keywords.[/b:2csjqn4t]
I guess you all know the keywords, so no need to list them here.
It is hard to fake a spam-mail just with keywords, so this is not so important. Just don't exaggerate.
-> [b:2csjqn4t]avoid future-dates in the mail-header.[/b:2csjqn4t]
Not hard to do.. Just don't do anything.

[/list:u:2csjqn4t]
[size=117:2csjqn4t][color=darkred:2csjqn4t][b:2csjqn4t]3) other stuff[/b:2csjqn4t][/color:2csjqn4t][/size:2csjqn4t]
[list:2csjqn4t]-> [b:2csjqn4t]your MTA should be able to resend the mail.[/b:2csjqn4t]
This is primarily because of the antispam-technic of graylisting, where the mail is held back until the sending MTA resends it a few times.
(graylisting assumes that spammers send their mails once, and that after 10 minutes they will be blacklisted)
another reason is that the receiving MTA can always be temporarily down.
-> [b:2csjqn4t]don't open your MTA for unauthenticated mail-relay[/b:2csjqn4t].
No need for more comments.
-> you may want to authenticate your mail using SSL, but then you need a certificate signed by a trusted authority, which costs (my mails are not signed)
-> PGP encrypted mail can be an alternative to SSL, but I have not tried that out.
-> you may want to sign your mail using DKIM (Domain Key Identified Mail), but this is new and not yet supported by many.
[/list:u:2csjqn4t]
Any additional comments on stuff I have forgotten are appreciated.
cheers!
- leonard