-1

I'm writing a newsletter module in PHP/MySQL.

How can I send email to site subscribers that doesn't cause my mail server get blocked? I mean it doesn't treat as a spam sender and how I can implement this ?

Thanks in Advance.

TheBlackBenzKid
  • 26,324
  • 41
  • 139
  • 209
  • use headers parameter in your mail function to avoid this – swapnesh Oct 31 '12 at 11:26
  • 1
    possible duplicate of [Prevent sent emails treated as junk mails using php mail function](http://stackoverflow.com/questions/746809/prevent-sent-emails-treated-as-junk-mails-using-php-mail-function) – mario Oct 31 '12 at 11:31
  • and also check [our search function](https://www.google.com/search?q=site:stackoverflow.com+php%20how%20to%20prevent%20mail%20getting%20marked%20as%20spam) – mario Oct 31 '12 at 11:31
  • do not use `mail()`. Use something less dumb, like PHP Mailer – Marcin Orlowski Oct 31 '12 at 11:44

3 Answers3

1
  1. Use Headers
  2. Make sure the code your sending has text and HTML versions - not just images
  3. Try to use SwiftMailer or a SMTP program like Sendgrid to avoid block lists
  4. If on a shared host make sure your host is white labelled otherwise you need MX records and IP listings and other things etc
  5. You cold limit your server connection via jQuery timeout while array the database so only sending 100 emails at a time etc.

Your question does not tell us your setup too.

TheBlackBenzKid
  • 26,324
  • 41
  • 139
  • 209
0

Add headers to avoid this --

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

reference

Also look at this link for further as there is no sure shot for this -- Link 2

Community
  • 1
  • 1
swapnesh
  • 26,318
  • 22
  • 94
  • 126
0

Instead of just reiterating everything that is said around the internet, i had might as well point you to some good articles to broaden your knowledge on how spam filters work:

How They Think:

Common Algorithm (how they learn from likes of spam assassin, akismet, etc):

Trigger Words to Avoid:

Asside from that, ensure you have correctly formed headers which can be achieved by using SwiftMail

Another very good way of of helping to ensure your messages get delivered and not marked as spam is to use plain text (not HTML). Though if HTML is a must, just ensure you also use a plain text version as well as HTML.

Depending on your circumstances you could pass this all off to a 3rd party mailing service such as mailchimp.com and they will help to ensure your emails get delivered (by correctly forming the headers, dealing with the legal requirements to fullfill the CAN-SPAM act etc).

Oh and a little tip, don't put the word "unsubscribe" in your email at all, use something like "i don't want these emails anymore" as it won't trigger such powerfull spam trigger words if any at all.

HenchHacker
  • 1,616
  • 1
  • 10
  • 16