-1

I've written code for sending an e-mail using php. I don't want to go that mail into spam. How can I avoid going that mail into spam?

<?php

$EmailTo = "name@example.com";
$Subject = "Enquiry from xxxx Website";
$name = $_REQUEST["name"];
$Body = $_REQUEST["body"];
$Subject = $_REQUEST["subject"];
$emailfrom = $_REQUEST["email"];
$phone = $_REQUEST["phone"];
$comments = $_REQUEST["comments"];
$todayis = date("l, j F Y, g:ia (T)") ;

// To send HTML mail, the Content-type header must be set
$headers .= "Organization: Sender Organization\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";

// Prepare email body text
$Body = "Here is the information collected from your online enquiry form. It was submitted by:\n";
$Body .= "Email: ";
$Body .= $todayis;
$Body .= "\n\n";

$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";

$Body .= "Email: ";
$Body .= $emailfrom;
$Body .= "\n";

$Body .= "Phone: ";
$Body .= $phone;
$Body .= "\n";

$Body .= "Comments: ";
$Body .= $comments;
$Body .= "\n";


// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$emailfrom>");

?>
David
  • 208,112
  • 36
  • 198
  • 279

5 Answers5

0

That's up to the spam filter marking it as spam, but make sure your DNS MX headers are configured properly.

Lusitanian
  • 11,012
  • 1
  • 41
  • 38
0

Make sure your server is not on a blacklist. If you are on a dynamic IP, most likely you are. Check at http://www.spamhaus.org/

cmastudios
  • 146
  • 1
  • 3
0

Mail classification is done at the receiving end, not the sending end. So whatever you do, you can't allways avoid being classifed as spam.

BTW: If you manage to find the 100% "I AM NOT SPAM" receipe, let me know. I have this exciting bsiness oportunity with an unclaimed fortune in Nigeria.

So: Fix th problem where it lies: At the receiving side. Make sure your host's IP address is whitelisted, just as you sender address (or sender/receiver tuple depending on your filer

Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
0

Like David said, it depends on the spam filters. Every email server/email provider has its own set of rules, but generally there are several common errors to avoid:

  1. Using spammy phrases, like “Click here!” or “Once in a lifetime opportunity!” Going crazy with exclamation points!!!!!!!!!!!!!!!

  2. USING ALL CAPS, WHICH IS LIKE SCREAMING AT THE TOP OF YOUR LUNGS VIA EMAIL (especially in the subject line)

  3. Coloring fonts bright red or green

  4. Coding sloppy HTML, usually from converting a Microsoft Word file to HTML

  5. Creating an HTML email that’s nothing but one big image, with little or no text (since spam filters can’t read images, they assume you’re a spammer that’s trying to trick them) Using the word “test” in the subject line (agencies run into this when sending drafts to clients for approval)

  6. Sending a test to multiple recipients within the same company (that company’s email firewall can only assume it’s a spam attack)

  7. Designing HTML email in Word and exporting the code to HTML (That code is sloppy, and spam filters hate it.)

You can refer to MailChimp's "How spam filter think" for a good read.

Captain Hypertext
  • 2,446
  • 4
  • 27
  • 36
Hoàng Long
  • 10,746
  • 20
  • 75
  • 124
0

I know you're sending plain text, but if you ever decide to send something in html, make sure not to use old, deprecated html tags. I got spam-listed once for having <font> tags and the like, which were being inserted by NicEdit.

Just a nugget for everyone out there.

Captain Hypertext
  • 2,446
  • 4
  • 27
  • 36