Laravel 6默认Auth重置密码时Gmail发送邮件报错:无发件人地址
Hey there, let's get this password reset email issue sorted out for you. The error you're seeing is pretty straightforward—Laravel can't send the email because it doesn't have a valid sender address configured. Let's walk through the fixes step by step:
1. Update Your .env File
The problem is right here in your .env config: MAIL_FROM_ADDRESS=null. Laravel needs a real email address here to use as the sender. Since you're using Gmail, set this to the same email you used for MAIL_USERNAME (Gmail requires the sender address to match your SMTP login unless you've set up aliases, which isn't necessary here).
Modify your .env to look like this:
MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=email@gmail.com MAIL_PASSWORD=djscsajhfslowhwo // Your app-specific password for 2FA MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=email@gmail.com MAIL_FROM_NAME="${APP_NAME}"
2. Clear Laravel's Configuration Cache
Laravel caches config values to speed things up, so even if you update .env, the old null value might still be stored. Run this command in your project root to clear the cache:
php artisan config:clear
If you're working in a production environment, you can re-cache the config after clearing it with:
php artisan config:cache
3. Verify the Configuration is Applied
To double-check that the fix worked, you can add a quick debug route (temporarily!) to confirm the sender address is set correctly:
// Add this to routes/web.php Route::get('/test-mail-config', function() { dd(config('mail.from')); });
Visit /test-mail-config in your browser—you should see an array with address set to email@gmail.com (not null). Once confirmed, you can delete this test route.
Quick Notes for Gmail Setup
- Make sure your app-specific password (the one you used for
MAIL_PASSWORD) was generated correctly for your Google account with 2FA enabled. - Gmail's SMTP server requires TLS encryption on port 587, which you already have configured correctly—no changes needed there.
That should resolve the sender address error, and your password reset emails should start sending as expected!
内容的提问来源于stack exchange,提问作者Salman

