3

I know it is a duplicate issue in StackOverFlow (Laravel SwiftMailer : Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required) however, I'm done all the remedies discussed there but still no luck. I'm using mailtrap.io using my GMail account. Here is the .env file and mail.php (under config):

.env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=XXXX
MAIL_PASSWORD=XXXX
MAIL_ENCRYPTION=tls

mail.php

'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailtrap.io'),
'port' => env('MAIL_PORT', 2525),
'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'niladriXXX@XXX.com'),
        'name' => env('MAIL_FROM_NAME', 'Niladri Banerjee'),
    ],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'sendmail' => '/usr/sbin/sendmail -t -i',
'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

After submitting the valid email from forgot password screen, it throws the following error:

Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required "

Please note: I have already ON 'Allow less secure apps' from "Sign-in & security" from my GMail.

Seeking your help.

PS: I'm running the project in localhost.

2 Answers2

6

I' may suggest you use this as well, it worked for me,

Please Note if you're using Gmail: create a gmail app password, but be sure to your 2 Step verification set up, from sign in and securiity, the following link: https://myaccount.google.com/apppasswords to setup app password, use that and follow procedure 2 after this return to set up gmail with smtp.

please note: code down below are for mail.php file

(do not forget to use: php artisan config:cache) after changes to .env file as well

return [

'driver' => env('MAIL_DRIVER', 'smtp'),

'host' => env('MAIL_HOST', 'smtp.mailtrap.io'),

'port' => env('MAIL_PORT', 2525),

'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'lxxxx@xxxx.com'),
        'name' => env('MAIL_FROM_NAME', 'myMail'),
    ],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),

'username' => env('MAIL_USERNAME'),//this setting in .env only leave as is here

'password' => env('MAIL_PASSWORD'),//this setting in .env only leave as is here

'sendmail' => '/usr/sbin/sendmail -bs',

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

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],
];

//procedure 2 for gmail return [

'driver' => env('MAIL_DRIVER', 'smtp'),

'host' => env('MAIL_HOST', 'smtp.gmail.com'),

'port' => env('MAIL_PORT', 587),

'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'lxxxx@gmail.com'),
        'name' => env('MAIL_FROM_NAME', 'myMail'),
    ],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),

'username' => env('MAIL_USERNAME'),//this setting in .env only leave as is here

'password' => env('MAIL_PASSWORD'),//this setting in .env only (use app password you created for gmail and PLEASE leave as is here

'sendmail' => '/usr/sbin/sendmail -bs',

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

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],
];

Hope it helps. Kind regards

Ndong Akwo
  • 592
  • 5
  • 13
0

add MAIL_FROM=mailtrap.io username to your .env file and php artisan config:cache.

if you see, mail.php needs this for authentication

if you see, mail.php needs this for authentication

Alrac
  • 11
  • 3