简体   繁体   中英

Unable to send password reset email using Laravel built in mail

I have been trying to get emails to send from Laravel for the past day without success. I have been testing locally using homestead and on a live linux server environment with no luck.

I have removed email settings from the .env file. and directly added the settings in my config/mail file.

so far I have tried office 365 settings, gmail and finally maligun, none of which send an email.

my settings are below.

'driver' => env('MAIL_DRIVER', 'mailgun'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
    'address' => env('MAIL_FROM_ADDRESS', 'postmaster@sandbox********099b827475b585029.mailgun.org'),
    'name' => env('MAIL_FROM_NAME', 'Test account'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('postmaster@sandbox****************099b827475b585029.mailgun.org'),
'password' => env('********************'),

I complete the password reset process via password/reset and it says the password reset link was sent successfully but it is never sent, the mailgun logs confirm no email was sent, the token is updated in the password_reset table

I ssh'd onto homestead and tested sending a email via mailgun using curl and this works.

if I set mail driver to SMTP I still get the same issue.

when setting the drive to 'log' the log files shows the email template etc.

any help would be appreciated.

thanks

What environment you working with? Local or production?

What kind of email you're using? Gmail or testing mail such as mailtrap?

If gmail did you active smtp from settings? Please provide more information.

Update:

let us test other ways to see if it makes any differences:

Go to your routes file web.php and comment this:

// Auth::routes();

Now add following routes:

// Authentication routes
Route::get('/login',['as'=>'login', 'uses' => 'Auth\LoginController@showLoginForm']);
      Route::post('/login', ['uses'=>'Auth\LoginController@login']);
      Route::get('/logout',['as'=>'logout', 'uses'=>'Auth\LoginController@logout']);
      Route::get('/register', ['as' => 'register', 'uses' => 'Auth\RegisterController@showRegisterForm']);
      Route::post('password/email', ['as'=>'password.email', 'uses'=>'Auth\ForgotPasswordController@sendResetLinkEmail']);
      Route::get('password/reset', ['as'=>'password.request', 'uses'=>'Auth\ForgotPasswordController@showLinkRequestForm']);
      Route::post('password/reset', ['as'=>'password.request', 'uses'=>'Auth\ResetPasswordController@reset']);
      Route::get('password/reset/{token}', ['as'=>'password.reset', 'uses'=>'Auth\ResetPasswordController@showResetForm']);
      Route::post('logout', ['as'=>'logout', 'uses'=>'Auth\LoginController@logout']);

Try and see if it works or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM