0

I'm implementing Laravel 5.8 built-in Email Verification feature but unfortunately I couldn't figure the bug.

I've added the MustVerifyEmail interface in ,y User Model.

This is my .ENV file in Laravel. Same configuration I used in mail.php.

.env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME="<My user Name>"
MAIL_PASSWORD="<My Password>"
MAIL_ENCRYPTION=ssl

Laravel Output

Kenny Horna
  • 13,485
  • 4
  • 44
  • 71
Ali Raza
  • 59
  • 2
  • 7

2 Answers2

0

You have to enable access to less secure apps in your google account security settings.

Dino Numić
  • 1,414
  • 2
  • 9
  • 17
0

For configuring gmail settings in laravel,

MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your_email_address@gmail.com
MAIL_PASSWORD=your_gmail_address_password
MAIL_FROM_ADDRESS=your_email_address@gmail.com
MAIL_FROM_NAME="YOUR_USER_NAME"
MAIL_ENCRYPTION=tls

Also update the following in mail.php

'pretend' => false,
    'stream' => [
        'ssl' => [
            'allow_self_signed' => true,
            'verify_peer' => false,
            'verify_peer_name' => false,
        ],
    ],

To test your configuration put this code on api.php

Route::get('/emailTest',function(){

    $emailData = [
        'from'      => 'admin_email@gmail.com',
        'email'     => 'user_email@gmail.com',
        'password'  => 'user_password',
    ];
    // "mails.toUser" : this is my email template in resources
    Mail::send('mails.toAdmin',['emailData' => $emailData],function($message) use ($emailData){
        $message->to($emailData['email'])
            ->from($emailData['from'])
            ->subject('New User Registration');
    });
});
Vipertecpro
  • 3,056
  • 2
  • 24
  • 43