0

I can't seem to get this to work:

ENV:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=my_acc@gmail.com
MAIL_PASSWORD=***
MAIL_ENCRYPTION=tls

In controller:

Mail::send('mail.template', ['post' => $post, 'user' => $user], function($message) {
            $message->to('my_acc@gmail.com', 'X Y')->subject('Comment');
        });

And I get error:

stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

I have tried adding this to StreamBuffer.php

$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;

And then I get this error:

Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted.

And even if I didn't get that error, I would like a solution, not a quick fix...

Norgul
  • 4,613
  • 13
  • 61
  • 144
  • Do you have two factor authentication enabled on your gmail account? – David Barker May 05 '16 at 12:38
  • No, but I tried with it also. Should it be enabled or not? Logic suggests not :) – Norgul May 05 '16 at 12:51
  • That's personal preference, if you do have it enabled you need to generate an app password to get access to it through your app. – David Barker May 05 '16 at 12:53
  • I'll keep that in mind...but I don't have it now, and the error is there – Norgul May 05 '16 at 13:04
  • For the record, I encountered the same issue and the [following post](https://stackoverflow.com/questions/40378067/symfony-swiftmailer-via-smtp-gmail-on-localhost-openssl-error) corrected this error. – NaeiKinDus Oct 24 '17 at 08:37

1 Answers1

0

Use your MAIL_ENCRYPTION=ssl and should work fine.

Luis Dalmolin
  • 3,416
  • 1
  • 18
  • 24