2012-11-22 259 views
4

我正在爲我的大學網站工作。我寫了一個PHP腳本,使用php mail function發送電子郵件。但問題是,我發送的所有電子郵件都將進入收件人垃圾郵件/垃圾郵件文件夾。Php郵件去收件人垃圾郵件/垃圾郵件文件夾

爲了解決這個問題

我嘗試了類似的問題,所有的步驟和答案在stackoverflowserverfault網站一樣: *正確頭 *精確從名稱等 但尚未問題沒有解決。

這是發送電子郵件的PHP代碼:

<?php 
$from_address="[email protected]".$_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="[email protected]"; 
mail($to, $subject, $body, $headers, "[email protected]{$_SERVER['SERVER_NAME']}"); 
echo "The Mail is SuccessFully Sent to :".$to; 
?> 

我還附上了原始電子郵件

Delivered-To: [email protected] 
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: <[email protected]> 
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 [email protected] 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 [email protected] designates 218.248.13.200 as permitted sender) [email protected] 
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 <[email protected]>; Thu, 22 Nov 2012 10:30:23 +0530 
Received: (from [email protected]) 
    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: <[email protected]> 
X-Authentication-Warning: www.nitw.ac.in: nobody set sender to [email protected] using -f 
To: [email protected]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?= <[email protected]> 
X-Mailer: PHP/5.3.5 

This is test Message 

(我在我的Gmail帳戶 「[email protected]」 獲得)同時,當我發現這種問題的罕見原因是server Blacklisting

然後我用下面的工具來測試它:http://www.mxtoolbox.com/SuperTool.aspx?action=mx%3anitw.ac.in#

我震驚,當上述工具測試發現我的黑名單服務器。如何這是真的因爲我上面附加的原始郵件說「:Received-SPF: pass (google.com: best guess record for domain of [email protected] designates 218.248.13.200 as permitted sender)

此外,如果我的服務器被列入黑名單,那我怎麼才能找到原因的黑名單,以及如何解決它

? UPD:影子評論:可以「X身份驗證警告:www.nitw.ac.in:沒有人設置發件人到[email protected]使用-f」msg是可能的原因嗎?如果是,我如何解決它?

謝謝!

+2

當我和這個實驗,問題是,我的服務器有一個動態IP地址。這是否適用於您?阻止這類服務器很常見,因爲它們很可能是垃圾郵件發送者。 – Shadow

+0

@Shadow:沒有它的靜態IP http://whatismyipaddress.com/ip/218.248.13.200 –

+0

不夠公平。另一件可能會將其標記爲垃圾郵件的郵件是不正確的發件人郵件頭。 'X-Authentication-Warning:www.nitw.ac.in:沒有人使用-f'將發件人設置爲[email protected],這對我來說看起來相當寬泛。你是否以「nobody @ localhost」發送郵件? 我會嘗試從php回踩 - 並試圖將膩子插入您正在使用的smtp服務器。 – Shadow

回答

2

設置SMTP服務器是一項棘手而繁瑣的任務,除非是你的工作日復一日地完成它......檢查你的服務器SSL證書是否使用授權的CA證書正確簽名。有時它可能是自問題簽署的證書,

或者你也可以嘗試使用Gmail作爲解決很多問題您的SMTP服務器..,Link

+0

謝謝Ajet,是的,我正在嘗試相同的,再次感謝:) –