Possible solution for SMTP failing - fgets(): SSL: Connection reset by peer


With OC v3.* the SMTP mail sending method didn’t work anymore for me. After some research and writing to my host support, I came up with following solution. The host support told me, that I need to add the local IP address of theirs:

In my .env file I added this line:


Then one should add this local domain to config/mail.php like this:

'smtp' => [
    'transport' => 'smtp',
    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
    'port' => env('MAIL_PORT', 587),
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME'),
    'password' => env('MAIL_PASSWORD'),
    'timeout' => null,
    'local_domain' => env('MAIL_EHLO_DOMAIN'), // this entry takes the local server domain from the .env

In my case the SMTP send mail option worked again with this solution.

1 Like

Hey Maki3000,

I’ve had a similar problem with v3.x.
My solution was changing the mailer, as described on this Stack Overflow page.

Setting the MAIL_MAILER variable to mail instead of smtp in the .env file fixed it.

Could you confirm that this also solves your problem? That might help to create a fix for OCMS.

I’m curious to know how/why this fixes the problem too…

Hey @johrclaessens,

No this doesn’t fix it. If I do that, then I get following error:

Call to undefined function Symfony\Component\Mailer\Transport\Smtp\Stream\proc_open()
1 Like