简体   繁体   English

当我使用phpmailer()发送电子邮件时,在Gmail帐户中收到警告消息

[英]Getting warning message in Gmail Account when I send email by using phpmailer()

I am using phpmailer() to send email from my website. 我正在使用phpmailer()从我的网站发送电子邮件。 But when It's sent email I see following warning message. 但是,当它发送电子邮件时,我看到以下警告消息。

在此处输入图片说明

I can't understand why it's showing and how can I fix this error message. 我不明白为什么会显示该消息以及如何解决此错误消息。 Can anyone tell me about it ? 有人可以告诉我吗?

Following is my code : 以下是我的代码:

<?php
  require_once("mail/PHPMailerAutoload.php");

  $mail = new PHPMailer;
  $mail->setFrom($email);
  $mail->addReplyTo('toemail@gmail.com', 'First Last');
  $mail->addAddress('toemail@gmail.com', 'First Last');
  $mail->Subject = 'PHPMailer mail() test';
  $mail->msgHTML(file_get_contents('mail/contents.html'), dirname(__FILE__));
  $mail->AltBody = 'This is a plain-text message body';
  $mail->addAttachment('mail/images/phpmailer_mini.png');

  if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
  } else {
    echo "Message sent!";
  }
  ?>

Easy, you could read about SPF DNS Record. 容易,您可以阅读有关SPF DNS记录的信息。

When you send and email, services like gmail check if the sender ip is the same that the domain of the email, for example: 当您发送电子邮件时,类似gmail的服务会检查发件人ip是否与电子邮件域相同,例如:

  1. You send an email as "foo@gmail.com" to "bar@hotmail.com". 您将电子邮件作为“ foo@gmail.com”发送到“ bar@hotmail.com”。 Your server ip is 1.1.1.1 您的服务器IP为1.1.1.1

  2. Hotmail receives an email from "foo@gmail.com" so check if gmail.com ip (2.2.2.2) is the same as your server (1.1.1.1). Hotmail收到来自“ foo@gmail.com”的电子邮件,因此请检查gmail.com ip(2.2.2.2)是否与您的服务器(1.1.1.1)相同。 The answer is NO, so the email is marked as spam. 答案是否定的,因此该电子邮件被标记为垃圾邮件。

  3. To avoid that your email will marked as spam, you could use phpmailer using a real google account and provide phpmailer the user and password to send the email. 为了避免您的电子邮件被标记为垃圾邮件,您可以使用具有实际Google帐户的phpmailer并向phpmailer提供用户名和密码来发送电子邮件。

I tried to explain you the situation very easy on point 2. Real situation is a bit complicated but the logic is the same, check ip sender and origin. 我试图在第二点很容易地向您解释这种情况。实际情况有些复杂,但逻辑是相同的,请检查ip发送方和来源。 Read about SPF (and dkim) because is what are you looking for :) http://en.wikipedia.org/wiki/Sender_Policy_Framework 阅读有关SPF(和dkim)的信息,因为您要寻找的是:) http://en.wikipedia.org/wiki/Sender_Policy_Framework

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 gmail 帐户和 PHPMailer 从 Heroku 服务器发送电子邮件 - Send email from Heroku server using gmail account and PHPMailer 使用phpmailer从网站向Gmail帐户发送消息 - Send message from website to gmail account using phpmailer 无法使用gmail帐户通过phpmailer发送电子邮件 - unable to send email with phpmailer with gmail account 使用phpmailer发送电子邮件到gmail帐户 - sending email to gmail account using phpmailer 为什么我在尝试使用phpmailer发送电子邮件激活新用户帐户时收到此错误 - Why am i getting this error when trying to send email for activation of new user account with phpmailer phpmailer-电子邮件未以gmail发送 - phpmailer - email not send in gmail PHPMailer使用Gmail Oauth2发送电子邮件 - PHPMailer send email using Gmail Oauth2 无法通过 PHPMailer 使用 Gmail SMTP 服务器发送 email,出现错误:SMTP 在端口 587 上提交邮件需要 AUTH。如何解决? - Unable to send email using Gmail SMTP server through PHPMailer, getting error: SMTP AUTH is required for message submission on port 587. How to fix? 使用PHPMailer为Gmail API格式化MIME消息时如何发送到BCC地址? - How to send to BCC address when using PHPMailer to format MIME message for Gmail API? 无法使用PHPMailer_v5.1通过gmail发送电子邮件 - Unable to send email through gmail using PHPMailer_v5.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM