PHP邮件错误发送电子邮件。 Hostgator是电子邮件提供商

时间:2018-03-01 16:26:59

标签: php email phpmailer mailer

自从一周以来,我一直坚持这一点。 尝试了所有可用的组合,没有任何效果。

这是我使用SMTP发送的功能

public function Send($Email,$subject,$message){
        $mail = new PHPMailer;
        $mail->isSMTP();
        //$mail->Mailer = 'smtp';
        $mail->SMTPDebug = 2;

        $mail->Host = smtp_host_addr; //defined as constant -like mail.example.com
        $mail->Port = smtp_port; //defined as constant tried 465,25,26

        //$mail->SMTPSecure = 'ssl';
        $mail->SMTPAuth = true;

        $mail->Username = Admin_Email; //defined as constant
        $mail->Password = Admin_pwd; //defined as constant
        $mail->AuthType = "LOGIN";
        $mail->setFrom(Admin_Email, 'Admin'); //defined as constant
        $mail->addReplyTo(Admin_Email, 'Admin'); //defined as constant
        $mail->addAddress($Email);
        $mail->Subject = $subject;
        $mail->msgHTML($message);
        //Replace the plain text body with one created manually
        $mail->AltBody = html2text($message); 
        if (!$mail->send()) {
            echo "Mailer Error: " . $mail->ErrorInfo;
            return false;
            //return $mail->ErrorInfo;
        } else {
            //echo "Message sent!";
            return true;
        }

    }

有时执行需要很长时间并且超时。或者提出错误说PHPMailer\PHPMailer\Exception: SMTP connect() failed.有点错误。

详细的错误报告在这里:

2018-03-01 16:26:17 SERVER -> CLIENT:
2018-03-01 16:27:46 CLIENT -> SERVER: EHLO localhost
2018-03-01 16:28:47 SERVER -> CLIENT:
2018-03-01 16:28:47 SMTP ERROR: EHLO command failed:
2018-03-01 16:28:47 SMTP NOTICE: EOF caught while checking if connected
SMTP Error: Could not connect to SMTP host.

非常感谢任何帮助。谢谢!

0 个答案:

没有答案