You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 6默认Auth重置密码时Gmail发送邮件报错:无发件人地址

Fixing "Cannot send message without a sender address" in Laravel 6 Password Reset

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 17:47:46