Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rameezisrar's avatar

Send Password reset link is not working (Expected response code 250 but got code "530",with message "530 5.7.1 Authentication required )

have configure smtp at .env with the mailtrap provided details.

But Send passwortd Reset Link is throwing this error

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

.env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=4ef9d5cd1dffd3
MAIL_PASSWORD=7524d9069d7f4d
MAIL_ENCRYPTION=null

mail.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Mail Driver
    |--------------------------------------------------------------------------
    |
    | Laravel supports both SMTP and PHP's "mail" function as drivers for the
    | sending of e-mail. You may specify which one you're using throughout
    | your application here. By default, Laravel is setup for SMTP mail.
    |
    | Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses",
    |            "sparkpost", "log", "array"
    |
    */

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

    /*
    |--------------------------------------------------------------------------
    | SMTP Host Address
    |--------------------------------------------------------------------------
    |
    | Here you may provide the host address of the SMTP server used by your
    | applications. A default option is provided that is compatible with
    | the Mailgun mail service which will provide reliable deliveries.
    |
    */

    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),

    /*
    |--------------------------------------------------------------------------
    | SMTP Host Port
    |--------------------------------------------------------------------------
    |
    | This is the SMTP port used by your application to deliver e-mails to
    | users of the application. Like the host we have set this value to
    | stay compatible with the Mailgun e-mail application by default.
    |
    */

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

    /*
    |--------------------------------------------------------------------------
    | Global "From" Address
    |--------------------------------------------------------------------------
    |
    | You may wish for all e-mails sent by your application to be sent from
    | the same address. Here, you may specify a name and address that is
    | used globally for all e-mails that are sent by your application.
    |
    */

    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'Example'),
    ],

    /*
    |--------------------------------------------------------------------------
    | E-Mail Encryption Protocol
    |--------------------------------------------------------------------------
    |
    | Here you may specify the encryption protocol that should be used when
    | the application send e-mail messages. A sensible default using the
    | transport layer security protocol should provide great security.
    |
    */

    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

    /*
    |--------------------------------------------------------------------------
    | SMTP Server Username
    |--------------------------------------------------------------------------
    |
    | If your SMTP server requires a username for authentication, you should
    | set it here. This will get used to authenticate with your server on
    | connection. You may also set the "password" value below this one.
    |
    */

    'username' => env('MAIL_USERNAME'),

    'password' => env('MAIL_PASSWORD'),

    /*
    |--------------------------------------------------------------------------
    | Sendmail System Path
    |--------------------------------------------------------------------------
    |
    | When using the "sendmail" driver to send e-mails, we will need to know
    | the path to where Sendmail lives on this server. A default path has
    | been provided here, which will work well on most of your systems.
    |
    */

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

    /*
    |--------------------------------------------------------------------------
    | Markdown Mail Settings
    |--------------------------------------------------------------------------
    |
    | If you are using Markdown based email rendering, you may configure your
    | theme and component paths here, allowing you to customize the design
    | of the emails. Or, you may simply stick with the Laravel defaults!
    |
    */

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

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

];

0 likes
9 replies
burlresearch's avatar

Given that you're getting "530 - Authentication required", I'd assume you have the route to the 'send password' endpoint somehow hidden behind your Auth middleware?

Perhaps you should post your routes/web.php file, or the output from: artisan route:list for us to take a look at...

rameezisrar's avatar

@burlresearch

routes/web.php

Route::get('/', 'WelcomeController@show');

Route::get('/home', 'HomeController@index');
Route::resource('home', 'HomeController')->middleware('auth');


Route::get('training/{pid}/{questid}', 'TrainingController@show')->middleware('auth');
Route::get('training/{pid}/{questid}/start-quiz', 'TrainingController@startQuiz')->middleware('auth');
Route::put('training/{pid}/{questid}/evaluate', 'UserTrainingHistoryController@store')->middleware('auth');

Route::post('training/{pid}/{questid}/videoWatched', 'UserTrainingHistoryController@hasWatched')->middleware('auth');

Route::resource('training', 'TrainingController')->middleware('auth');

Route::get('presentation/{name}', 'ToolController@presentation')->middleware('auth');
Route::resource('tools', 'ToolController')->middleware('auth');

Route::get('branding/my_certificate/{id}', 'BrandingController@certificate')->middleware('auth');
Route::get('branding/download/{pid}/{id}', 'BrandingController@resource')->middleware('auth');
Route::resource('branding', 'BrandingController')->middleware('auth');

Route::get('workouts/{pid}/{categoryid}', 'WorkoutController@scripts')->middleware('auth');
Route::resource('workouts', 'WorkoutController')->middleware('auth');


burlresearch's avatar

Where is your Auth::routes() declaration? Did you run php artisan make:auth to provide your default Auth routes? This may be your whole issue.

Also, an alternative to cleanup your routing file may be to use a route-group (up to you, worth a mention):

<?php
Auth::routes();     // generated by `artisan make:auth`!!!

Route::get('/', 'WelcomeController@show');
Route::resource('home', 'HomeController');          // check constructor for 'auth' middleware

Route::middleware(['auth'])->group(function () {    // 'middleware group' can cleanup routing file
    Route::get('training/{pid}/{questid}', 'TrainingController@show');
    Route::get('training/{pid}/{questid}/start-quiz', 'TrainingController@startQuiz');
    Route::put('training/{pid}/{questid}/evaluate', 'UserTrainingHistoryController@store');

    Route::post('training/{pid}/{questid}/videoWatched', 'UserTrainingHistoryController@hasWatched');

    Route::resource('training', 'TrainingController');

    Route::get('presentation/{name}', 'ToolController@presentation');
    Route::resource('tools', 'ToolController');

    Route::get('branding/my_certificate/{id}', 'BrandingController@certificate');
    Route::get('branding/download/{pid}/{id}', 'BrandingController@resource');
    Route::resource('branding', 'BrandingController');

    Route::get('workouts/{pid}/{categoryid}', 'WorkoutController@scripts');
    Route::resource('workouts', 'WorkoutController');

});

Without Auth::routes() you may be missing the required predefined routes for your password-reset paths?

$ artisan route:list
...
| POST      | login                  | Auth\LoginController@login                        |
| GET|HEAD  | login                  | Auth\LoginController@showLoginForm                |
| POST      | logout                 | Auth\LoginController@logout                       |
| POST      | password/email         | Auth\ForgotPasswordController@sendResetLinkEmail  |
| POST      | password/reset         | Auth\ResetPasswordController@reset                |
| GET|HEAD  | password/reset         | Auth\ForgotPasswordController@showLinkRequestForm |
| GET|HEAD  | password/reset/{token} | Auth\ResetPasswordController@showResetForm        |
| GET|HEAD  | register               | Auth\RegisterController@showRegistrationForm      |
| POST      | register               | Auth\RegisterController@register                  |
1 like
rameezisrar's avatar

@burlresearch I am using Spark, It comes with Auth setup already.

Auth::routes()

has been replaced in some other file and has been working just fine. The problem is something else

burlresearch's avatar

The reason I thought to look at routing, is that your error seems to indicate you are hitting a route, during password-reset, that is protected by Auth, and so that's why the reset emails cannot be sent.

If you think the error is with MailTrap auth - then you could simply test it with a quick artisan command...

1 like
burlresearch's avatar

I think your credentials are wrong - check those at MailTrap:

   Swift_TransportException  : Failed to authenticate on SMTP server with username "4ef9d5cd1dffd3" using 3 possible authenticators
.../Swift/Transport/Esmtp/AuthHandler.php: 181
  181:             throw new Swift_TransportException(
  182:                 'Failed to authenticate on SMTP server with username "'.
  183:                 $this->username.'" using '.$count.' possible authenticators'
  184:                 );
  185:         }
  186:     }
1 like
rameezisrar's avatar

@burlresearch now the error is gone and I can see the email on MailTrap but I am unable to receive email on my real Gmail account. Am I doing something wrong here?

burlresearch's avatar
Level 40

Great - glad to hear this problem is solved.

In order to actually send email out into the wild - you'll have to use one of the many other drivers that Laravel offers. That comes with a little more configuration, and a working SMTP account somewhere. Perhaps look over some of the options:

https://laravel.com/docs/5.6/mail#introduction

The entire point of MailTrap is that it does not send mail out, but rather 'traps' it, and shows you what would be sent.

1 like

Please or to participate in this conversation.