2017-02-19 49 views
1

早上好, 我想删除gmail警告'gmail couln't验证... @ ...发送此消息'当我用php发送邮件。删除发送邮件时未验证的gmail警告邮件用PHP发送邮件

我知道这是因为我使用的电子邮件功能php没有认证,所以我尝试PHPMailer和PHP梨,但页面转向,直到无限且没有任何事情发生。 我的主机是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); 
?> 

谢谢。

回答

1

我最近也遇到过这个问题,并且意识到问题不是来自PHP脚本,正如我第一次想到的,但是没有为域名记录SPF。

SPF记录标识哪些邮件服务器被允许从特定域名发送电子邮件。如果该域名没有SPF记录,则Gmail无法验证电子邮件是否来自正确的位置。

巧合的是,我也与1 & 1,所以请参阅here for how to set up SPF records for 1&1。你需要使用的值是:

v=spf1 include:_spf.perfora.net include:_spf.kundenserver.de -all 

您还可以检查电子邮件通过单击箭头在Gmail电子邮件的顶部,并按下“显示原始”通过了SPF测试。

enter image description here

+0

感谢它的工作,用简单的鄂麦,但不与PEAR邮件,但它足以让我。 – bormat