我需要向本地用户发送电子邮件。但问题Outlook认为电子邮件是垃圾邮件(网络钓鱼)。是否可以添加特殊标题或其他东西来解决这个问题?
$to = $email;
$subject = 'Registration;
$message = '<html><body>';
$message = '<h3>Hello </h3> <br>Text Text<br>TextText: Text<br> Login name: '.$user_name ;
$message .= '</body></html>';
$headers = 'From: emailname@localdomain'. "\r\n" .
'Reply-To: MyName@localdomain' . "\r\n" .
'Content-Type: text/html; charset=ISO-8859-1' ."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
答案 0 :(得分:1)
以下标题通常适用于我:
$headers = array();
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/plain; charset=iso-8859-1';
$headers[] = 'From: E-Mail Name <emailname@localdomain>';
$headers[] = 'Reply-To: My Name <MyName@localdomain>';
$headers[] = 'Subject: ' . $subject;
$headers[] = 'X-Mailer: PHP/' . phpversion();
然后发送时,只是内爆:
mail($to, $subject, $email, implode("\r\n", $headers));
但是,我建议您使用PHPMailer邮件:https://github.com/PHPMailer/PHPMailer