【发布时间】:2012-11-10 11:27:54
【问题描述】:
我正在为我的大学网站工作。我写了一个 php 脚本,使用php mail function 发送电子邮件。但问题是,我发送的所有电子邮件都进入了收件人的垃圾邮件/垃圾文件夹。
为了解决它:
我尝试了stackoverflow 和serverfault 网站中类似问题的所有步骤和答案,例如: *正确的标题 *准确的名称等 但是问题还没有解决。
这是发送邮件的php代码:
<?php
$from_address="webmaster@".$_SERVER['SERVER_NAME'];
$from_name="webmaster";
$headers = "MIME-Version: 1.0\r\n"
."Content-Type: text/plain; charset=utf-8\r\n"
."Content-Transfer-Encoding: 8bit\r\n"
."From: =?UTF-8?B?". base64_encode($from_name) ."?= <$from_address>\r\n"
."X-Mailer: PHP/". phpversion();
$subject="Web Mail Testing";
$body="This is test Message";
$to="riteshkumargupta1990@gmail.com";
mail($to, $subject, $body, $headers, "-fwebmaster@{$_SERVER['SERVER_NAME']}");
echo "The Mail is SuccessFully Sent to :".$to;
?>
我还附上了原始电子邮件(我在我的 gmail 帐户“riteshkumargupta1990@gmail.com”中收到的)
Delivered-To: riteshkumargupta1990@gmail.com
Received: by 10.204.8.210 with SMTP id i18csp146000bki;
Wed, 21 Nov 2012 20:58:12 -0800 (PST)
Received: by 10.68.219.164 with SMTP id pp4mr1119127pbc.72.1353560291776;
Wed, 21 Nov 2012 20:58:11 -0800 (PST)
Return-Path: <webmaster@nitw.ac.in>
Received: from www.nitw.ac.in (www.nitw.ac.in. [218.248.13.200])
by mx.google.com with ESMTPS id sh10si3456960pbb.293.2012.11.21.20.58.10
(version=TLSv1/SSLv3 cipher=OTHER);
Wed, 21 Nov 2012 20:58:11 -0800 (PST)
Received-SPF: pass (google.com: best guess record for domain of webmaster@nitw.ac.in designates 218.248.13.200 as permitted sender) client-ip=218.248.13.200;
Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of webmaster@nitw.ac.in designates 218.248.13.200 as permitted sender) smtp.mail=webmaster@nitw.ac.in
Received: from www.nitw.ac.in (localhost.localdomain [127.0.0.1])
by www.nitw.ac.in (8.13.8/8.13.8) with ESMTP id qAM50M0h016190
for <riteshkumargupta1990@gmail.com>; Thu, 22 Nov 2012 10:30:23 +0530
Received: (from nobody@localhost)
by www.nitw.ac.in (8.13.8/8.13.8/Submit) id qAM50McG016189;
Thu, 22 Nov 2012 10:30:22 +0530
Date: Thu, 22 Nov 2012 10:30:22 +0530
Message-Id: <201211220500.qAM50McG016189@www.nitw.ac.in>
X-Authentication-Warning: www.nitw.ac.in: nobody set sender to webmaster@nitw.ac.in using -f
To: riteshkumargupta1990@gmail.com
Subject: Web Mail Testing
X-PHP-Originating-Script: 0:mailer.php
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
From: =?UTF-8?B?d2VibWFzdGVy?= <webmaster@nitw.ac.in>
X-Mailer: PHP/5.3.5
This is test Message
另外,在谷歌搜索时,我发现此类问题的不常见原因是 server Blacklisting。
然后我使用以下工具对其进行测试:http://www.mxtoolbox.com/SuperTool.aspx?action=mx%3anitw.ac.in#
当上述工具测试发现我的服务器在黑名单中时,我感到震惊。这是怎么回事?因为我上面附上的原始邮件说“:Received-SPF: pass (google.com: best guess record for domain of webmaster@nitw.ac.in designates 218.248.13.200 as permitted sender)
另外,如果我的服务器被列入黑名单,那么如何找到黑名单的原因以及如何解决?
统一更新: 来自 Shadow 评论:“X-Authentication-Warning: www.nitw.ac.in: nobody set sender to webmaster@nitw.ac.in using -f” msg 可能是原因吗?如果是,我该如何解决?
谢谢!
【问题讨论】:
-
当我尝试这个时,问题是我的服务器有一个动态 IP 地址。这适用于你吗?阻止这类服务器很常见,因为它们很可能是垃圾邮件发送者。
-
@Shadow : 不是静态 IP whatismyipaddress.com/ip/218.248.13.200
-
很公平。可能将其标记为垃圾邮件的另一件事是不正确的发件人标头。
X-Authentication-Warning: www.nitw.ac.in: nobody set sender to webmaster@nitw.ac.in using -f对我来说看起来很可疑。您是否以nobody@localhost发送电子邮件?我会尝试从 php 退一步 - 并尝试将 putty 放入您正在使用的 smtp 服务器。 -
@shadow:那么我应该如何解决这个错误。我正在使用松鼠邮件 SMTP 服务器。
-
我想再添加一件事:15 天前,完全相同的代码、相同的服务器和相同的配置用于向收件人收件箱发送电子邮件,但突然从 2-3 天后,邮件发送到垃圾邮件/垃圾文件夹
标签: webserver sendmail spam php