php 每次我的邮件在 phpmailer 中变成垃圾邮件时

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9988325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 08:02:02  来源:igfitidea点击:

Everytime my mail goes to spam in phpmailer

phpemailphpmaileremail-spam

提问by sujal

Here are my codes for sending mail:

这是我发送邮件的代码:

    $fullname = $_POST['fullname'];
    $email = $_POST['email'];
    $telephone = $_POST['telephone'];
    $email = $_POST['email'];
    $date = $_POST['date'];
    $time = $_POST['time'];
    $adult = $_POST['adult'];
    $children = $_POST['children'];
    $company_name = $_POST['company_name'];
    $addition = $_POST['addition'];
    $confirm = $_POST['confirm'];

    $body = '
    <table width="100%" border="0" cellpadding="0">
      <tr>
        <td>Dear Sir,
        </td>
      </tr>
      <tr>
        <td><b>Booking request from '.$fullname .'</b><br /><br />
          <u>The details provided are:</u><br />
          <p>Name : '.$fullname.'<br />
          E-mail Address: '.$email.'<br />
          Telephone: '.$telephone.'<br />
          Date: '.$date.'<br />
          Time: '.$time.'<br />
          Adult: '.$adult.'<br />
          Children: '.$children.'<br />
          Company Name: '.$company_name.'<br />
           Confirm by: '.$confirm .'<br />
         Additional Requirements: '.$addition.'<br />
          </p>
           </td>
      </tr>
      <tr>
        <td>
        <p>Thank you,<br />
        Kaavya Cuisine
        </p></td>
      </tr>
    </table>
    ';

    $to         = '[email protected]';
    $subject    = 'Booking Request';
    $sitename='Website Name';

    $mail = new PHPMailer(); 
    $mail->AddReplyTo($to,$sitename);
    $mail->SetFrom($email,$fullname);


    $mail->AddAddress($to, $sitename);
    $mail->Subject    = $subject;

    $mail->MsgHTML($body);
    $mail->Send();

Every time I send the mail, it goes in to spam. Does anyone know why this is happening?

每次我发送邮件时,它都会变成垃圾邮件。有谁知道为什么会这样?

回答by ab_dev86

Based on you code i notice that you are sending an email directly from you web page on your domain.

根据您的代码,我注意到您直接从您域上的网页发送电子邮件。

For example you used an @hotmail.com address.

例如,您使用了@hotmail.com 地址。

When the recipient receive the emails the mail service of the recipient may test a reverse DNS of the sender of the mail. So the sender is from @hotmail.combut the mail comes from your domain which of course is not hotmail.com.

当收件人收到电子邮件时,收件人的邮件服务可能会测试邮件发件人的反向 DNS。所以发件人来自@hotmail.com但邮件来自您的域,当然不是hotmail.com

So I receive a mail from an address @hotmail.combut the IP sender isn't related at all with domain hotmail.com: that's SPAM!

所以我收到一封来自某个地址的邮件,@hotmail.com但 IP 发件人与域hotmail.com完全没有关系:那是垃圾邮件!

http://en.wikipedia.org/wiki/Reverse_DNS_lookup

http://en.wikipedia.org/wiki/Reverse_DNS_lookup

I think a possible solution is: in you PHP code use authenticate with SMTP and from there send the mail!

我认为一个可能的解决方案是:在您的 PHP 代码中使用 SMTP 身份验证并从那里发送邮件!

回答by mim

Normally, an email is marked spam if its "From:" header value's domain part does not match the domain that is actually sending the email.

通常,如果电子邮件的“发件人:”标头值的域部分与实际发送电子邮件的域不匹配,则该电子邮件会被标记为垃圾邮件。

The easiest way to bypass this is to use a "From:" that matches your domain, and use a "Reply-To:" header to the email that you set in "From:" header

绕过此问题的最简单方法是使用与您的域匹配的“发件人:”,并对您在“发件人:”标头中设置的电子邮件使用“回复:”标头

For eg: if you are sending mail from mydomain.comand your from email is [email protected], you should change your headers to this:

例如:如果您从mydomain.com发送邮件,而您的发件人电子邮件是[email protected],则应将标题更改为:

From: [email protected]

Reply-To: [email protected]

来自:[email protected]

回复:[email protected]

回答by Ujjwal

if this is your full codes then you have to write the path of the PHPMailer thats it.

如果这是您的完整代码,那么您必须编写 PHPMailer 的路径。

Ex-

前任-

require '/...../PHPMailer-master/class.phpmailer.php';

require '/....../PHPMailer-master/PHPMailerAutoload.php';

require '/......./PHPMailer-master/class.smtp.php';   

the above will help you.

以上将帮助你。

回答by Scott Machlovski

spam filter of Google or Outlook or whichever you use do this automatically. I believe there is no way make the mail go to inbox programmatically. usually this happens because the sending server is already marked as spam by somebody. The way i found is go to the gmail account mark the item as 'important' in gmail and 'Add to Safe senders' in Outlook.

Google 或 Outlook 或任何您使用的垃圾邮件过滤器会自动执行此操作。我相信没有办法让邮件以编程方式进入收件箱。通常发生这种情况是因为发送服务器已被某人标记为垃圾邮件。我发现的方法是转到 gmail 帐户,在 gmail 中将该项目标记为“重要”,并在 Outlook 中将其标记为“添加到安全发件人”。