1

I want to configure a custom email (not gmail) with TLS using Laravel and I can't make it work.

The error I get is:

stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:\nerror:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

In my .env file I have:

MAIL_DRIVER=smtp
MAIL_HOST=mail.**********.com
MAIL_PORT=587
MAIL_USERNAME=system@**********.com
MAIL_PASSWORD=**********
MAIL_FROM_ADDRESS=system@**********.com
MAIL_ENCRYPTION=tls

I tried the same account in a non Laravel PHP project and it works just fine. In that project, I have this option that I think is the key:

$mailer->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
        )
    );
$mailer->SMTPAuth = true;
$mailer->SMTPSecure = 'tls';

How can I configure this options in Laravel? Or is another mistake? Thanks for your help.

Dilhan Nakandala
  • 301
  • 5
  • 24
  • Possible solution? https://stackoverflow.com/a/30686838/11801683 – jewishmoses Jul 09 '20 at 23:45
  • As another user said in that post: "that answer doesn't describe the consequences of that change. If you change it to 'mail' it will then send the mail via PHP mail meaning that it will be subject to higher spam scores because PHP is essentially spoofing the email." Tks anyway. – Fryla- Cristian Marucci Jul 09 '20 at 23:58

1 Answers1

2

Finally when I change the MAIL_ENCRYPTION to null, it worked just fine. I assume that is a server configuration problem, I'll check it with the sysadmin. Regards

  • Disabling encryption seems like a poor solution to your problem, as does disabling security measures in your "non Laravel PHP project" – miken32 Sep 22 '21 at 19:15