简体   繁体   中英

PHPMailer SMTP works on local server, but not on production server

I have the following configuration for PHPMailer, which worked perfectly on my localhost machine, but doesn't send emails in production:

//Send a notification email
try {
    $mail = new PHPMailer(true);
    $mail->IsSMTP();
    $mail->SMTPDebug = 0;
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = "tls";
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 587;
    $mail->Username = $username;
    $mail->Password = $password;
    $mail->AddAddress($_POST['username'], $name);
    $mail->SetFrom("no-reply@a-domain-setup-in-google-apps.com", "No-Reply");
    $mail->Subject = $subject;
    $mail->AltBody = $altBody;
    $mail->MsgHTML($bodyHTML);
    $mail->Send();
} catch (phpmailerException $e) {
    echo $e->errorMessage();
    exit;
} catch (Exception $e) {
    echo $e->getMessage();
    exit;
}

When I set SMTP debug equal to 2 , here is what I get:

SMTP -> FROM SERVER:220 mx.google.com ESMTP bo7sm9593967igb.2 
SMTP -> FROM SERVER: 250-mx.google.com at your service, [204.93.159.80] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250 PIPELINING 
SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS 
SMTP -> FROM SERVER: 250-mx.google.com at your service, [204.93.159.80] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH 250-ENHANCEDSTATUSCODES 250 PIPELINING 
SMTP -> FROM SERVER:250 2.1.0 OK bo7sm9593967igb.2 
SMTP -> FROM SERVER:250 2.1.5 OK bo7sm9593967igb.2 
SMTP -> FROM SERVER:354 Go ahead bo7sm9593967igb.2 
SMTP -> FROM SERVER:250 2.0.0 OK 1341071123 bo7sm9593967igb.2

It all looks good, but I can't send emails any more.

I am positive my Google Apps account that this is sending emails from is configured properly (as it worked before), and my logon credentials are correct.

Any ideas?

Your emails are most likely not delivering because .co.cc domains are associated with spam and generally non-legitimate sites; Google has banned all .co.cc domains from its index .

It would thus make sense that they are blocking or heavily filtering emails from these domains as well.

Consider using a normal domain, like one ending with .com .

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