dongzheng8463 2017-10-27 07:09
浏览 17

我正在使用php邮件程序功能如何防止我的电子邮件不是垃圾邮件

email function

     function sendAuthEmail($to,$subject,$body) 
        { 
            $mail_host                      = 'smtp.gmail.com';
            $mail_port                      = 465;
            $mail_username                  = 'abs.webref@gmail.com';
            $mail_password                  = '123#';

            if (!class_exists("phpmailer")) 
            {
            include("application/third_party/email/class.phpmailer.php");
            }
            $mail = new PHPMailer();
            $mail->IsSMTP(); // set mailer to use SMTP
            $mail->SMTPDebug        = 1; // debugging: 1 = errors and messages, 
           2 = messages only
            $mail->Host             = $mail_host; // specify main and backup server
            $mail->SMTPAuth         = true; // turn on SMTP authentication
            $mail->SMTPSecure       = 'ssl'; // secure transfer enabled REQUIRED for Gmail
            $mail->Port             = $mail_port; // or 587
            $mail->Username         = $mail_username; // SMTP username
            $mail->Password         = $mail_password; // SMTP password
            $mail->From             = "contact@geniustechgroup.com"; 
            $mail->FromName         = "Genius Tech Group";
            $mail->AddAddress($to); // Email on we want to send mail
            $mail->IsHTML(true);
            $mail->Subject              = $subject;
            $mail->Body                 = $body;
            if(!$mail->Send()) 
            {  
                return false;
            } 
            else 
            {
                return true;
            }
        }  
  • 写回答

2条回答 默认 最新

  • dongzilu0178 2017-10-27 07:24
    关注

    More often then not, the outcome of your email being delivered straight to the spam folder is not a result of the agent using for sending it. But rather it is related to the settings of your domain's DNS and of the sending server. Each email is evaluated and if it doesn't meet a threshold score, it will be either considered spam or totally bounced(in extreme cases).

    The content of the email will also play a role, as well as the sending domains's reputation.

    Make sure to check if your domain or the server's ip are not blacklisted.

    First things you should do is to make sure that your emails are DKIM signed and the dns of your domain has the proper SPF record. You can get an overview of these two reading this article.

    I also suggest you to do a bit of "troubleshooting" first. You can send one of your emails to a service such mail-tester.com and you will discover the main areas where you could improve.

    Good luck!

    评论

报告相同问题?

悬赏问题

  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗