PHP邮件功能只发送垃圾邮件

时间:2015-10-26 11:05:07

标签: php function email spam

我对PHP邮件功能有疑问。虽然我使用它只会发送被检测为垃圾邮件的电子邮件,但更改或添加标题并没有任何区别。

这是我的代码:

            $to      = $email;
            $subject = "The Subject";
            $message = "This is a message<br/>
                        This is another line<br>
                        And another line..<br>";
            $headers = "From: example@mydomain.com\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: example@mydomain.com\r\n";
            $headers .= "Return-Path: example@mydomain.com\r\n";

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

有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

 Use $headers = "From: noreply@mydomain.com \r\n";
  instead of
$headers = "From: example@mydomain.com\r\n";
                          OR 
   Use the following: its working fine for me:
    $touser=$email;
    $subjectAdmin= "demo";
    $headersAdmin = "From: noreply@demo.com\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);