2010-11-23 96 views
1

我在這裏有一個問題,我的PHP腳本發送的郵件從未被傳送到我的收件箱,而是垃圾郵件。有關如何將其發送到收件箱的任何幫助。謝謝你們 這裏是我的代碼示例這裏PHP郵件總是出現在垃圾郵件文件夾中

public function sendMail($name,$email,$message) 
{ 
    $this->validateInput($name,"Empty Name","Invalid Name"); 
    $this->validateEmail($email,"Empty Email","Invalid Email"); 
    $this->validateLargeData($message,"Invalid Message","Empty Message","Message Too Short"); 
    if (empty($this->errors)) 
    { 
     $fromName = $name; 
     $fromEmail = $email; 
     $from = "From: $fromName <$fromEmail>\r\n"; 
     $reply = "Reply-To: $fromEmail\r\n";  
     $mime = "MIME-Version: 1.0\r\n"; 
     $content = "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
     $headers = $from.$reply.$mime.$content; 
     if (mail("[email protected]","Contact",$message,$headers)) 
     { 
      echo "<div class='success1'>Thank you $name, we will get back you immediately.</div>"; 
     } 

    } 
    else 
    { 
     echo "<div class=''>"; 
     echo "</div>"; 
    } 
} 

編輯 PLS是我使用

$fromName = $name; 
$fromEmail = $email; 
$from = "From: $fromName <$fromEmail>\r\n"; 
$reply = "Reply-To: $fromEmail\r\n";  
$mime = "MIME-Version: 1.0\r\n"; 
$content = "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
$mailer = "X-Mailer: PHP's mail() Function"; 
$headers = $from.$reply.$mime.$content.$mailer; 

@cyberomin

+0

@皮卡,過去這樣做。有關這個問題的任何幫助? – Cyberomin 2010-11-23 21:34:30

+1

@Cyber​​omin你以前的意思是什麼?我不明白 – 2010-11-23 21:35:21

+1

Pekka想說的是:爲了提高人們幫助你的機會,建議首先接受你以前的問題的一些答案。 – 2010-11-23 21:44:28

回答

2

確保你的頭是完整的:

$headers = "MIME-Version: 1.0\n"; 
$headers .= "Content-type: text/plain; charset=iso-8859-1\n"; 
$headers .= "From: aaa.bbb <[email protected]>\n"; 
$headers .= "X-Mailer: PHP's mail() Function\n"; 
mail("[email protected]", "subject","message",$headers); 

如果你是共享主機,這也許是因爲有您的IP被列入黑名單的垃圾郵件發送者。

我可以做的最好的建議是嘗試一種不同的方式發送您的電子郵件。例如phpmailerSwift Mailer

0

的頭信息,我們只能給你一個確切回答如果您將垃圾郵件文件夾中的郵件標題提供給我們,但我認爲這是因爲您正從包含消費者互聯網連接的IP範圍內的IP計算機發送郵件納秒。消費電腦的電子郵件通常是垃圾郵件