Question: I wrote a PHP script to send emails.

My script is like this:

```
$headers =  'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: abc@yahoo.com' . "\r\n";

// Email Variables
$toUser  = "someone@yahoo.com"; // recipient
$subject = "testing"; // subject
$body    = "<html><body><p>
             Example of including an image via html \<img\> tag:
             <br>
             <img src='../images/profile.jpg'>
             <br>
             My new picture
             <br></p></body></html>"; // content

if (mail($toUser,$subject,$body,$headers)) {
    echo "sent";
} else {
    echo "failed";
}

```

Well, of course I use a valid email address for sender and receiver. I did receive the email, but it goes to junk mail. So I went for google research. Is it because of my "header" script problem? If it isn't, then what could cause my script to send a junk mail? Any solution?

Answer: 
Use [mxtoolbox.com](http://mxtoolbox.com/) to check the servers IP to be blacklisted or not. As well this website can help you with a couple of email related checks. 

Of course there are a long list of checks running inside spam filters. As already suggested, check the email headers for details about the spam filters rating of the spam email. 

Hope that helps!
1. On your server try to sort your SPF (Sender Policy Framework, Google for SPF record) record out.
2. Make sure you send your e-mails from an existing account on your server/domain.
3. Make sure you have the reply-to address in your header.

These are the basic things you can try.