abc
abc

Reputation: 1

i am using php mailer function how i can prevent my email not in spam

email function

     function sendAuthEmail($to,$subject,$body) 
        { 
            $mail_host                      = 'smtp.gmail.com';
            $mail_port                      = 465;
            $mail_username                  = '[email protected]';
            $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             = "[email protected]"; 
            $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;
            }
        }  

Upvotes: 0

Views: 128

Answers (2)

DimoZZa
DimoZZa

Reputation: 26

You can try to ensure "from" equal smtp login. You're having different values now.

Upvotes: 1

Alex
Alex

Reputation: 187

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!

Upvotes: 0

Related Questions