Jump to content

Phpmailer going to spam


eskimopest

Recommended Posts

I've working on a script to send emails with phpmailer and everything works fine but on a live server, goes to spam. This is my code:

 

    // SEND EMAIL CODE
    include('vendor/PHPMailerAutoload.php');
    include('vendor/class.smtp.php');

    $email = new PHPMailer();

    $email->IsSMTP();
    $email->SMTPAuth = true;
    $email->SMTPKeepAlive = true;
    $email->Host = 'hostname';
    $email->Port = 465;
    $email->Username = 'my_username@host.com';
    $email->Password = 'my_pass';

    $email->SMTPSecure = 'ssl';
    $email->setFrom('my_email@host.com', 'name');
    $email->addReplyTo('my_email@host.com', 'name');
    $email->Subject   = $subject;
    $email->Body      = $message;

    // set the emails to send the message
    foreach($emails_to as $mail) {
        $email->addAddress($mail);
    }
    // send the email
    if(!$email->Send()) {
        echo "Message was not sent <br />PHPMailer Error: " . $email->ErrorInfo;
    }
    else {
        echo "Message has been sent";
    }

    $mail->clearAddresses();
    $mail->clearAttachments();

 

 

 

What am i doing wrong? could it be that the name of setFrom() is not set properly?

Please help. Tks in advance

Link to comment
Share on other sites

Simply using PHPMailer does not mean your emails will go through.

 

You have to find out why it went to spam. Does the From address not match the actual sender address? Did the email fail SPF validation? Does the email look spammy?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.