早上好,当我用php发送电子邮件时,我想删除gmail警告:“gmail不能验证...@.发送了这条消息”。
我知道这是因为我使用没有身份验证的电子邮件函数php,所以我尝试了PHPMailer和pear,但是页面一直翻到无限大,什么也没有发生。我的主机是1&1,我尝试用gmail代替smtp和帐户,而不是1&1,但结果是一样的。
<?php
// Pear Mail Library
require_once "Mail.php";
$from = '<***@motelavigna.co>'; //change this to your email address
$to = '<***@gmail.com>'; // change to address
$subject = 'Insert subject here'; // subject of mail
$body = "Hello world! this is the content of the email"; //content of mail
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject
);
$smtp = Mail::factory('smtp', array(
'host' => 'auth.smtp.1and1.fr',
'port' => '465',
'auth' => true,
'username' => '***@***.co', //co is not an error
'password' => '***' // your password
));
// Send the mail
$mail = $smtp->send($to, $headers, $body);
?>谢谢。
发布于 2017-02-19 21:52:50
我最近也遇到了这个问题,并意识到问题不是来自PHP脚本,正如我最初想的那样,而是因为没有一个SPF的域名记录。
SPF记录标识哪些邮件服务器被允许从特定域名发送电子邮件。如果域没有SPF记录,那么Gmail无法验证电子邮件是否来自正确的地方。
巧合的是,我也有1&1,所以请参阅这里介绍如何为1和1建立SPF记录。。您需要使用的值是:
v=spf1 include:_spf.perfora.net include:_spf.kundenserver.de -all您还可以检查电子邮件是否通过SPF测试,点击Gmail中电子邮件顶部的箭头,然后按下“显示原件”。

https://stackoverflow.com/questions/42329276
复制相似问题