简体   繁体   中英

Mail go to spam intead of inbox using smtp mail method in php

I want to send mail with smtp mail method using PHP.Now mail go to spam instead of inbox,i am using smtp mail method.I had set the hostname,username and password.

  <?php

  define("SMTP_HOST", "mail.test.net"); //Hostname of the mail server
  define("SMTP_PORT", "25"); //Port of the SMTP like to be 25, 80, 465 or 587
  define("SMTP_UNAME", "tttt"); 
  //Username for SMTP authentication any valid   email created in your domain
  define("SMTP_PWORD", "tttt"); //Password for SMTP authentication
  ?>

   //smtp mail
  $mail   = new PHPMailer;
  $mail->Host = SMTP_HOST; 
  $mail->Port = SMTP_PORT; 
  $mail->SMTPAuth = true; 
  $mail->Username = SMTP_UNAME; 
  $mail->Password = SMTP_PWORD; 
  $mail->AddReplyTo("test@test.com", "zamisoft"); 
  $mail->SetFrom("test@test.com", "zamisoft.com"); 
  $mail->Subject = $subject; 
  $mail->AddAddress($to, '');
  $mail->MsgHTML($message);
  $send = $mail->Send(); 
  $mail->ClearAddresses();

  //smtp mail

Anybody give any solution for these issue?

There is a very similar question here regarding using PHPMailer and Spam - https://stackoverflow.com/a/16717647/1676190

This does sound more like a configuration issue with your mail server and/or your DNS server. Your mail server does not appear to be "trusted" enough, so you don't get enough "positive" points from GMail (and mail clients). I notice that you're using postfix as your mailer... Have you configured it properly?

I would suggest you configure postfix first. For example, here's a guide on how to do it in CentOS:

http://wiki.centos.org/HowTos/postfix

Second, you should add an SPF record to your DNS server:

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

Third, it would be good to have a reverse lookup entry for your server:

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

You will need to do the above and some more to make sure that clients don't flag your mail as spam, and you don't get blacklisted

Here's a good list of things to do to avoid getting blacklisted:

http://www.supportsages.com/blog/2010/07/prevent-your-mailip-from-getting-marked-as-spamblacklisted-a-few-tips/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM