0

I have a question about the PHP mail function. While I'm using it only sends emails which are detected as Spam, and changing or adding headers doesn't make any difference.

Here is my code:

            $to      = $email;
            $subject = "The Subject";
            $message = "This is a message<br/>
                        This is another line<br>
                        And another line..<br>";
            $headers = "From: [email protected]\r\n";
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
            $headers .= "X-Priority: 3\r\n";
            $headers .= "Reply-To: [email protected]\r\n";
            $headers .= "Return-Path: [email protected]\r\n";

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

Could someone please help me out?

Amrinder Singh
  • 5,300
  • 12
  • 46
  • 88

1 Answers1

0
 Use $headers = "From: [email protected] \r\n";
  instead of
$headers = "From: [email protected]\r\n";
                          OR 
   Use the following: its working fine for me:
    $touser=$email;
    $subjectAdmin= "demo";
    $headersAdmin = "From: [email protected]\r\n"; 
    $headersAdmin .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $messageuser ='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01  
    Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html lang="en"> 
    <head>
    <title>demo</title> 
    </head> 
    <body> 
    <div style="margin:0 auto;">
    <p>message</p>
    <div style="clear:both;font-size:14px; text-align:left; width:100%;"> 
    <br/>
    </div>
    </div>
    </body>
    </html>'; 
     $emailSenduser = mail($touser,$subjectAdmin,$messageuser,$headersAdmin);