Jump to content

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
https://forums.phpfreaks.com/topic/304287-phpmailer-going-to-spam/
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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.