2015-12-01 34 views
1

我嘗試使用郵件功能來發送郵件,但它總是在垃圾郵件文件夾發送,並通過@ gator4120.hostgator.com如何使用郵件功能

<?php 
$subject = "Registration completed !!!! "; 
$from= "From: [email protected]\n"; 
$message ="Dear ".$varfname.",\n"; 
$message = $message."\r\nCongratulations! \n"; 
$message = $message."You are now a member of B2B Portal.\n"; 
$message = $message."Your profile is under screening and will be activated within next 24 hrs.\n "; 
$header .= "Reply-To: admin <$from>\r\n"; 
$header .= "Return-Path: admin <$from>\r\n"; 
$header .= "From: admin <$from>\r\n"; 
$header .= "Organization: The organization\r\n"; 
$header .= "Content-Type: text/plain\r\n"; 
if (mail("[email protected]", $subject, $message, $header)) { 
echo "The email has been sent!"; 
} else { 
echo "The email has failed!"; 
} 
?> 
+1

如果TI去垃圾郵件的,因爲電子郵件服務器決定它是一個垃圾郵件,除了使用更可靠的域名,以及減少可疑消息並警告客戶可能發生的情況之外,您無法將其作爲發件人做太多工作。這不是你可以決定的,也不是客戶的一方。對於第二部分,您需要提供更多數據,但請注意,您根本不會將您的變量傳遞給郵件,也不會將其格式錯誤。 – mikus

+0

有沒有什麼方法可以修復它 – Bhavesh

回答

0

主機網站這個信息來發送郵件收件箱中的正在使用hostgator來託管您的網站。 mail()只是一個內置函數,可以將郵件傳遞到本地SMA(例如sendmail),從此取決於您的機器配置。這裏的配置設置爲gator4120.hostgator.com作爲郵件服務器,許多其他使用hostgator的用戶也使用該配置。因此,使用郵件服務器發送電子郵件的其他人可能已被標記爲垃圾郵件,因此您的電子郵件自然也被標記爲垃圾郵件。解決方案,這是對用戶不同的郵件服務器像MailChimp link

嘗試使用

  1. phpmailer
  2. swiftmailer
+0

我還會檢查一下從頭部格式是否真的正確, – mikus

+0

我認爲是因爲服務器在垃圾郵件箱中獲取郵件是否正確? – Bhavesh

+0

是的,因爲其他人已將收到的電子郵件標記爲垃圾郵件。哪些不是由您發送的,而是由使用相同郵件服務器的其他人發送的。在Gmail中,如果將電子郵件標記爲垃圾郵件,則據報道將其視爲基於郵件服務器或電子郵件ID的垃圾郵件。 –