Could not connect to SMTP host

后端 未结 2 838
野趣味
野趣味 2020-12-06 11:00

SMTP Error: Could not connect to SMTP host. Message could not be sent.

Mailer Error: SMTP Error: Could not connect to SMTP host.

I c

相关标签:
2条回答
  • 2020-12-06 11:16

    You can enable debug mode with the SMTPDebug property, e.g.:

    $mail = new PHPMailer();
    // 1 = errors and messages
    // 2 = messages only
    $mail->SMTPDebug  = 2;
    

    Error messages will be echoed to screen.

    Update:

    A permission denied error message using fsockopen() suggests that the user PHP runs as is not allowed to open a socket. If you'd double-checked that there's no firewall, it's possible that's a SELinux problem :-?

    0 讨论(0)
  • 2020-12-06 11:25

    OS CentOS 6.3

    Couldn’t send emails

    after some reserch turned out that SELinux is blocking the communication

    SELinux is activated and configured by default. As such SELinux does not allow Apache (httpd,phpmailer) to use the sendmail function and make any sort of network connection.

    Using the getsebool command we can check if httpd demon is allowed to make a connection over the network and send an email.

    getsebool httpd_can_sendmail
    getsebool httpd_can_network_connect
    

    This command will return a boolean on or off. If its off, we can set it on using the following:

    sudo setsebool -P httpd_can_sendmail 1
    sudo setsebool -P httpd_can_network_connect 1
    

    Now you can test your php, code to see if SendMail work properly or not.

    0 讨论(0)
提交回复
热议问题