Spam classification is something that is done by the recipient's mail server. You cannot block it or (in most cases) detect it.
Some mails are also rejected by mail servers which check for correctness (i.e. rejecting obviously forged messages etc).
Here are some tips which will decrease the probability of your mail being classed as spam:
- Ensure that the domain names in your envelope sender (The sender specified by your MTA; possibly configurable with sendmail - f parameter; alternatively, set automatically. Consult your mail server admin.) and "From" sender exist and can receive mail
- Ensure that the domain names in your envelope sender / From do not have a Sender policy framework entry which prohibits mails from your server(s)
- Do not forge the "From" header - don't specify a "From" header for a domain you don't control or have permission to send from
- DO send the message in plain text if possible
- If not, send it as a multipart/alternative with text and HTML as necessary (NOTE: this may be nontrivial)
- Ensure that your mail server and mail message conform to all relevant standards.
Mark