【发布时间】:2014-09-17 07:27:02
【问题描述】:
我正在使用 PHPMailer 从我的网站发送自动电子邮件,在测试时,我注意到当我通过 Gmail 从网站发送邮件时,php mailer 发送的电子邮件会在收件人端生成以下警告:
此邮件的发送者可能不是:example@gmail.com 了解更多 报告网络钓鱼。
但是当我使用其他电子邮件(如 yahoo、outlook)时,我的$contact_email 中没有任何电子邮件。请帮我解决这个问题。
PHP 邮件程序代码:
<?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();
?>
【问题讨论】:
-
这与PHPMailer无关。您正在使用 PHP 的
mail()函数...