PHPMailer无法正常工作,无法发送电子邮件,并说邮件发送成功。见附件

时间:2018-09-21 11:58:37

标签: php phpmailer

PHPMailer将不会发送电子邮件。 PHPMailer没有显示任何错误,但是没有发送我的电子邮件。这是我的phpMailer设置:

require 'PHPMailer/src/Exception.php';
    require 'PHPMailer/src/PHPMailer.php';
    require 'PHPMailer/src/SMTP.php';


     $mail = new PHPMailer(true);                              // Passing `true` enables exceptions
    try {
        //Server settings
        $mail->SMTPDebug = 2;                                 // Enable verbose debug output
        $mail->isSMTP();                                      // Set mailer to use SMTP
        $mail->Host = 'sg2plcpnl0032.prod.sin2.secureserver.net';  // Specify main and backup SMTP servers
        $mail->SMTPAuth = true;                               // Enable SMTP authentication
        $mail->Username = 'website@website.com';                 // SMTP username
        $mail->Password = 'password';                           // SMTP password
        $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
        $mail->Port = 465;                                    // TCP port to connect to

        //Recipients
        $mail->setFrom('website@website.com', 'website');
        $mail->addAddress('$email_id', '$name');     // Add a recipient
        $mail->addAddress('info@website.com');               // Name is optional
        $mail->addReplyTo('info@website.com', 'website');
        $mail->addCC('info@website.com');
        $mail->addBCC('info@website.com');


        //Content
        $mail->isHTML(true);                                  // Set email format to HTML
        $mail->Subject = 'Your Car website Information ';
        $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

        $mail->send();
        echo 'Message has been sent';
    } catch (Exception $e) {
        echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
    }

它显示以下错误

errormessage.jpg

0 个答案:

没有答案