我正在使用PHPMailer从我的网站发送自动电子邮件,在测试时,我注意到当我通过Gmail从网站发送邮件时,php邮件发送的电子邮件在收件人端产生以下警告:此消息可能尚未发送者:example@gmail.com了解更多报告网络钓鱼 . 但是当我使用其他电子邮件(如雅虎,Outlook)时,我的 $contact_email 中没有收到任何电子邮件 . 请帮我解决这个问题 .
PHP邮件代码:
global $_REQUEST;
$response = array('error'=>'');
$user_name = substr($_REQUEST['user_name'], 0, 20);
$user_email = substr($_REQUEST['user_email'], 0, 40);
$user_msg = $_REQUEST['user_msg'];
$contact_email = 'contact.arefin@gmail.com';
if (trim($contact_email)!='') {
$subj = 'Message from Official Website';
$msg = "Name: $user_name
E-mail: $user_email
Message: $user_msg";
$head = "Content-Type: text/plain; charset=\"utf-8\"\n"
. "X-Mailer: PHP/" . phpversion() . "\n"
. "Reply-To: $user_email\n"
. "To: $contact_email\n"
. "From: $user_email\n";
if (!@mail($contact_email, $subj, $msg, $head)) {
$response['error'] = 'Error send message!';
}
} else
$response['error'] = 'Error send message!';
echo json_encode($response);
die();
?>