Wordpress and WP Mail SMTP plugin

Discussion in 'ISPConfig 3 Priority Support' started by JohnnyBeGood, Feb 11, 2020.

  1. JohnnyBeGood

    JohnnyBeGood Member

    Hi,

    So I setup exactly as in this tutorial https://soulstudio.info/blog/wordpress-smtp-setup-tutorial/
    but when I try to send test email full Error Log for debugging shows this:
    Code:
    Versions:
    WordPress: 5.3.2
    WordPress MS: No
    PHP: 7.3.11-1~deb10u1
    WP Mail SMTP: 1.8.1
    
    Params:
    Mailer: smtp
    Constants: No
    ErrorInfo: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
    Host: server1.mydomain.us
    Port: 465
    SMTPSecure: ssl
    SMTPAutoTLS: bool(true)
    SMTPAuth: bool(true)
    
    Server:
    OpenSSL: OpenSSL 1.1.1d 10 Sep 2019
    SMTP Debug:
    2020-02-11 17:28:31 Connection: opening to ssl://server1.mydomain.us:465, timeout=300, options=array ()
    
    2020-02-11 17:30:43 Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://server1.mydomain.us:465 (Connection timed out) [/var/www/clients/client1/web1/web/wp-includes/class-smtp.php line 298]
    
    2020-02-11 17:30:43 SMTP ERROR: Failed to connect to server: Connection timed out (110)
    
    SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Is this on an ISPConfig system?
    I ask because when I have installed Wordpress, I have done nothing extra and Wordpress has been able to send e-mail.
    Does the e-mail server work, that is it can send and receive e-mails?
    Is the above statement true? You have verified twice you really really have done exactly as written there?
     
  3. JohnnyBeGood

    JohnnyBeGood Member

    Yes
    Yes, I can send and recieve emails using roundcude.
    Yes. If I turn off that plugin and try to send email using contact form it goes through. It does not work when I enable the plugin?

    upload_2020-2-11_10-17-44.png
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Try using port 587 instead of 465 if you want to use phpmailer. And you probably need a valid ssl cert for the mail system incl chain cert install in case you have not done that yet.

    Another option that is probably easier to setup is that you use smtp server: localhost, port: 25 plus the email address and password of a local smtp account.
     
  5. JohnnyBeGood

    JohnnyBeGood Member

    Just tried 587 and after sometime trying to send test email it gives me pretty much same error. What is preventing it connect on either of those ports?
    Can you please point me in the right direction on how to install valid ssl cert for the mail system incl chain cert install?
    I'm using "The Perfect Server - Debian 10 (Buster)" VMWare image.

    Here's port 25 error:
    Code:
    Versions:
    WordPress: 5.3.2
    WordPress MS: No
    PHP: 7.3.11-1~deb10u1
    WP Mail SMTP: 1.8.1
    
    Params:
    Mailer: smtp
    Constants: No
    ErrorInfo: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
    Host: server1.mydomain.us
    Port: 25
    SMTPSecure: string(0) ""
    SMTPAutoTLS: bool(true)
    SMTPAuth: bool(true)
    
    Server:
    OpenSSL: OpenSSL 1.1.1d 10 Sep 2019
    SMTP Debug:
    2020-02-11 18:54:37 Connection: opening to server1.mydomain.us:25, timeout=300, options=array ()
    
    2020-02-11 18:56:48 Connection failed. Error #2: stream_socket_client(): unable to connect to server1.mydomain.us:25 (Connection timed out) [/var/www/clients/client1/web1/web/wp-includes/class-smtp.php line 298]
    
    2020-02-11 18:56:48 SMTP ERROR: Failed to connect to server: Connection timed out (110)
    
    SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Most likely the ssl cert of the mail system or the ssl client lib of the used php version is not compatible with the tls version that the mail system is using.
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    https://github.com/ahrasis/LE4ISPC
     
  8. JohnnyBeGood

    JohnnyBeGood Member

    Ok, so I updated:
    /etc/postfix/smtpd.cert
    /etc/postfix/smtpd.key

    with current valid wildcard ssl info. Same ssl is used for ISPconfig.
    Rebooted server and I'm still getting same time out error.
    The system is on php v7.3
    Any other suggestions? Is it pretty common not to be able to use any plugins to connect to the mail server on the ISPconfig?
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, but did you install the SSL chain certs as well in postfix? without chain certs, PHP is probably not able to verify the SSL cert and therefore it fails to connect.

    Your problem is not ispconfig specific, ispconfig is not involved in this process at all. Its a connection between PHP and postfix that fails.
     
  10. JohnnyBeGood

    JohnnyBeGood Member

    I did try all of them:
    /etc/letsencrypt/live/www.mydomain.us/privkey.pem > /etc/postfix/smtpd.key
    /etc/letsencrypt/live/www.mydomain.us/chain.pem > /etc/postfix/smtpd.cert
    and
    /etc/letsencrypt/live/www.mydomain.us/fullchain.pem
    > /etc/postfix/smtpd.cert

    Rebooted server after each change but getting same timeout.

    I did telnet test and got this:
    Code:
    [[email protected] ~]# telnet server1.mydomain.us 465
    telnet: Unable to connect to remote host: Connection timed out
    Trying 192.168.0.100...
    [[email protected] ~]#
    Its trying to connect to 192.168.0.100 which is part of VMWare image setup and is not part of my server network. Where can I change that to server1.mydomain.us real IP?
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    The chain file is configured like this:

    smtpd_tls_CAfile = /etc/letsencrypt/live/www.mydomain.us/chain.pem

    then restart postfix.

    And you shall use port 587 and not 465. Port 587 is the submission port which is typically used to send email with TLS.

    /etc/hosts
     
  12. JohnnyBeGood

    JohnnyBeGood Member

    After changing /etc/hosts it is able to connect to the mail server now but gives slightly different error:

    Code:
    Versions:
    WordPress: 5.3.2
    WordPress MS: No
    PHP: 7.3.11-1~deb10u1
    WP Mail SMTP: 1.8.1
    
    Params:
    Mailer: smtp
    Constants: No
    ErrorInfo: SMTP Error: Could not connect to SMTP host.
    Host: server1.mydomain.us
    Port: 587
    SMTPSecure: tls
    SMTPAutoTLS: bool(true)
    SMTPAuth: bool(true)
    
    Server:
    OpenSSL: OpenSSL 1.1.1d 10 Sep 2019
    SMTP Debug:
    2020-02-12 19:35:02 Connection: opening to server1.mydomain.us:587, timeout=300, options=array ()
    
    2020-02-12 19:35:02 Connection: opened
    
    2020-02-12 19:35:02 SERVER -> CLIENT: 220 server1.mydomain.us ESMTP Postfix (Debian/GNU)
    
    2020-02-12 19:35:02 CLIENT -> SERVER: EHLO www.mydomain.com
    
    2020-02-12 19:35:02 SERVER -> CLIENT: 250-server1.mydomain.us250-PIPELINING250-SIZE250-VRFY250-ETRN250-STARTTLS250-ENHANCEDSTATUSCODES250-8BITMIME250-DSN250-SMTPUTF8250 CHUNKING
    
    2020-02-12 19:35:02 CLIENT -> SERVER: STARTTLS
    
    2020-02-12 19:35:02 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
    
    2020-02-12 19:35:02 Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed [/var/www/clients/client1/web1/web/wp-includes/class-smtp.php line 374]
    
    SMTP Error: Could not connect to SMTP host.
    
    2020-02-12 19:35:02 CLIENT -> SERVER: QUIT
    
    2020-02-12 19:35:02
    
    2020-02-12 19:35:02
    
    2020-02-12 19:35:02 Connection: closed
    
    SMTP Error: Could not connect to SMTP host.

    I was manually entering info in /etc/postfix/smtpd.key and /etc/postfix/smtpd.cert
    Are you saying I should enter smtpd_tls_CAfile = /etc/letsencrypt/live/www.mydomain.us/chain.pem in /etc/postfix/main.cf ? what about:
    smtpd_tls_cert_file=/etc/letsencrypt/live/www.mydomain.us/fullchain.pem smtpd_tls_key_file=/etc/letsencrypt/live/www.mydomain.us/privkey.pem
    Anything else needs to be enabled in /etc/postfix/main.cf?
     
  13. JohnnyBeGood

    JohnnyBeGood Member

    Ok, I think I got it to work.
    I added:
    smtpd_tls_cert_file=/etc/letsencrypt/live/www.mydomain.com/fullchain.pem
    smtpd_tls_key_file=/etc/letsencrypt/live/www.mydomain.com/privkey.pem
    smtpd_tls_CAfile=/etc/letsencrypt/live/www.mydomain.com/chain.pem

    instead of:
    # TLS parameters
    smtpd_tls_cert_file = /etc/postfix/smtpd.cert
    smtpd_tls_key_file = /etc/postfix/smtpd.key

    inside /etc/postfix/main.cf
    rebooted server and I was able to send test email!
    Obviously www.mydomain.com is domain hosted on my server server1.mydomain.us
    Do I need to add anything else to /etc/postfix/main.cf other than above? I found above in this post so I'm not sure if that's all what is needed.


    upload_2020-2-12_13-24-53.png
     
    Last edited: Feb 12, 2020
  14. till

    till Super Moderator Staff Member ISPConfig Developer

    that should be ok.
     
  15. JohnnyBeGood

    JohnnyBeGood Member

    Great. Thank you!
     

Share This Page