OJS 3xx Using SMTP don't send email__Help___

The advice nhuthua has for testing gmail will also be relevant to your SMTP connection. Turn on show_stacktrace to get details of the connection failure in your error log.

Dear Leader,
Many thank you for your help.
Minh Nhut

Hi, I tested gmail and it worked, mail came and everything was like it should be.

Then I tested smtp server that I need to work and it didn’t. I get this error:

[06-Jun-2019 16:01:36 Asia/Kuwait] Invalid address: (Reply-To):
[06-Jun-2019 16:01:36 Asia/Kuwait] Connection: opening to mail.arhiv.hr:25, timeout=300, options=array()
[06-Jun-2019 16:01:36 Asia/Kuwait] Connection: opened
[06-Jun-2019 16:01:36 Asia/Kuwait] SERVER → CLIENT: 220 G7V-01.hdarhiv.local Microsoft ESMTP MAIL Service ready at Thu, 6 Jun 2019 15:01:31 +0200

[06-Jun-2019 16:01:36 Asia/Kuwait] CLIENT → SERVER: EHLO arhivskivjesnik.arhiv.hr

[06-Jun-2019 16:01:36 Asia/Kuwait] SERVER → CLIENT: 250-G7V-01.hdarhiv.local Hello [REMOVED]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH NTLM
250-8BITMIME
250-BINARYMIME
250 CHUNKING

[06-Jun-2019 16:01:36 Asia/Kuwait] CLIENT → SERVER: STARTTLS

[06-Jun-2019 16:01:41 Asia/Kuwait] SERVER → CLIENT: 500 5.3.3 Unrecognized command

[06-Jun-2019 16:01:41 Asia/Kuwait] SMTP ERROR: STARTTLS command failed: 500 5.3.3 Unrecognized command

[06-Jun-2019 16:01:41 Asia/Kuwait] SMTP Error: Could not connect to SMTP host.
[06-Jun-2019 16:01:41 Asia/Kuwait] CLIENT → SERVER: QUIT

[06-Jun-2019 16:01:41 Asia/Kuwait] SERVER → CLIENT: 221 2.0.0 Service closing transmission channel

[06-Jun-2019 16:01:41 Asia/Kuwait] Connection: closed
[06-Jun-2019 16:01:41 Asia/Kuwait] SMTP connect() failed. [Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub]
[06-Jun-2019 16:01:41 Asia/Kuwait] SMTP connect() failed. [Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub]

This error indicates that the reply-to address is missing. Does the sender within OJS have a valid email address set?

This error indicates that OJS tried to secure the connection, but the SMTP server doesn’t support this kind of security negotiation.

Ok, I set it up to SSL now and this is new error I get:

[11-Jun-2019 16:09:31 Asia/Kuwait] Connection: opening to ssl://mail.arhiv.hr:25, timeout=300, options=array()
[11-Jun-2019 16:09:32 Asia/Kuwait] Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol [C:\inetpub\vjesnik\lib\pkp\lib\vendor\phpmailer\phpmailer\src\SMTP.php line 326]
[11-Jun-2019 16:09:32 Asia/Kuwait] Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [C:\inetpub\vjesnik\lib\pkp\lib\vendor\phpmailer\phpmailer\src\SMTP.php line 326]
[11-Jun-2019 16:09:32 Asia/Kuwait] Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://mail.arhiv.hr:25 (Unknown error) [C:\inetpub\vjesnik\lib\pkp\lib\vendor\phpmailer\phpmailer\src\SMTP.php line 326]
[11-Jun-2019 16:09:32 Asia/Kuwait] SMTP ERROR: Failed to connect to server: (0)
[11-Jun-2019 16:09:32 Asia/Kuwait] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
[11-Jun-2019 16:09:32 Asia/Kuwait] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

In SMTP.php line 326 is: $socket_context in

    if ($streamok) {
        $socket_context = stream_context_create($options);
        set_error_handler([$this, 'errorHandler']);
        $this->smtp_conn = stream_socket_client(
            $host . ':' . $port,
            $errno,
            $errstr,
            $timeout,
            STREAM_CLIENT_CONNECT,
            $socket_context
        );
        restore_error_handler();

You are trying to use an ssl:// protocol with a traditional unsecured SMTP port 25. The SMTP server is responding that it doesn’t know what to do with an SSL protocol. It is highly unlikely that an SMTP server listening on port 25 will be speaking SSL. For more background information, see:

Check with your SMTP server’s system administrator or hosting provider to identify what the correct port is for your SMTP server, and what security options are available to you on the SMTP server. You can then configure OJS to use those settings.

Dear Slipsa,
You can test ssl:// SMTP send email port: 465 or 587. if ssl:// don’t send gmail, you change ssl to tls port 587 (attentive: smtp_password = ***) before I incurring error as you.
Ex:
gmail-smtp-03
Thanks and good lucky!
Minh Nhut

So, I contacted administrator and it appears that everything I set up was right, except that they didn’t set up which type of authentification it is. They set it up to TLS so the new error I get is:

[19-Jun-2019 14:56:24 Asia/Kuwait] Connection: opening to mail.arhiv.hr:25, timeout=300, options=array()
[19-Jun-2019 14:56:24 Asia/Kuwait] Connection: opened
[19-Jun-2019 14:56:24 Asia/Kuwait] SERVER → CLIENT: 220 G7V-01.hdarhiv.local Microsoft ESMTP MAIL Service ready at Wed, 19 Jun 2019 13:56:20 +0200

[19-Jun-2019 14:56:24 Asia/Kuwait] CLIENT → SERVER: EHLO arhivskivjesnik.arhiv.hr

[19-Jun-2019 14:56:24 Asia/Kuwait] SERVER → CLIENT: 250-G7V-01.hdarhiv.local Hello [REMOVED]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-AUTH NTLM
250-8BITMIME
250-BINARYMIME
250 CHUNKING

[19-Jun-2019 14:56:24 Asia/Kuwait] CLIENT → SERVER: STARTTLS

[19-Jun-2019 14:56:24 Asia/Kuwait] SERVER → CLIENT: 220 2.0.0 SMTP server ready

[19-Jun-2019 14:56:25 Asia/Kuwait] Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [W:\vhosts\vjesnik\lib\pkp\lib\vendor\phpmailer\phpmailer\src\SMTP.php line 405]
[19-Jun-2019 14:56:25 Asia/Kuwait] SMTP Error: Could not connect to SMTP host.
[19-Jun-2019 14:56:25 Asia/Kuwait] CLIENT → SERVER: QUIT

[19-Jun-2019 14:56:25 Asia/Kuwait] SERVER → CLIENT:
[19-Jun-2019 14:56:25 Asia/Kuwait] SMTP ERROR: QUIT command failed:
[19-Jun-2019 14:56:25 Asia/Kuwait] Connection: closed
[19-Jun-2019 14:56:25 Asia/Kuwait] SMTP connect() failed. [Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub]
[19-Jun-2019 14:56:25 Asia/Kuwait] SMTP connect() failed. [Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub]

SMTP.php line 405:

    set_error_handler([$this, 'errorHandler']);
    $crypto_ok = stream_socket_enable_crypto(
        $this->smtp_conn,
        true,
        **$crypto_method**
    );
    restore_error_handler();

I really need help about it, it has to work and I just don’t know how to fix it…

The system administrator’s configuration of TLS is incomplete or untrusted. Send the error message OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed to your system administrator. They will either need to update the certificate they used on the server, or will need to provide you instructions on how to get your server to trust the certificate authority which they used. One option may be to turn off certificate verification for OpenSSL. This is a possible but undesirable configuration choice, so if they suggest that, be sure you know the full implications.

So, in the second case, turning off certificate verification for OpenSSL, where can it be done?

This instruction will need to come from your system administrator or hosting provider. It is a system configuration and not an OJS configuration and will vary from system to system.

Ok, and what about downloading cacert.pem and setting up path to it in php.ini in openssl.cafile?

Am I missing some kind of configuration of PHPMailer or is it just due the system administration? I mean, is it possible that maybe they don’t use this certificate? What if that’s the case?

Sorry if I’m boring you, I’m just trying to figure it out and learn something new.

Yes, this is really just system administration. Essentially, SSL certificates only work because clients have a list of trusted certificate authorities which can digitally sign server certificates. The certificate authority which signed the certificate in use by your SMTP server is not trusted by your OJS server. This could be because the SMTP server administrator used a generally untrusted CA, or perhaps your OJS server is missing one or more generally trusted CAs. You can manually import the certificate as “trusted” in a number of ways, but this will be system-specific and I can’t provide guidance on that.

Ok, thank you so much for your help. I hope we’ll make this work.