【问题标题】:PHP mail function only send spam [duplicate]PHP邮件功能仅发送垃圾邮件[重复]
【发布时间】:2015-10-26 11:05:06
【问题描述】:

我有一个关于 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);

有人可以帮帮我吗?

【问题讨论】:

  • 如果你至少使用 Php-Mailer 会更好。

标签: php function email spam


【解决方案1】:
 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);

【讨论】:

    猜你喜欢
    • 2013-08-16
    • 2015-05-01
    • 2016-05-27
    • 2016-10-07
    • 2014-12-21
    • 2022-01-09
    • 1970-01-01
    • 2017-08-31
    相关资源
    最近更新 更多