[英]PHP mail function is sending emails in Gmail's SPAM folder, How to get rid of it?
我正在使用此代碼:
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
它將電子郵件發送到我的gmail的SPAM文件夾。
建議任何解決方案。
我不想使用任何PEAR MAIL類型的方式來發送電子郵件或不想要求並包含任何文件。
此功能可以正常工作,而無需包括/不需要任何其他php文件。
您應該使用PHP手冊中的正確標題
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
全部在標題中。 我不知道GMail在內部如何工作,但是我在我的項目中發現,設置Reply-To can Content-Type標頭似乎可以解決此問題。
有關執行此操作的示例,請參見PHP mail()文檔 。
(注意:我有一個PHP問卷/響應系統,該系統設置了這些標頭,並且電子郵件正確地傳遞到了GMail,Hotmail和Yahoo! Mail)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.