Laravel配置Mailgun遇投递失败:无法发送至曾退信地址
Hey there, let's work through this Mailgun issue you're hitting with your Laravel site. That error message gives us a clear clue right off the bat—here's how to resolve it step by step:
1. Understand the Root Cause
The error means Mailgun has flagged ibrahim_hasan_eng@hotmail.com as a bounced address. This usually happens because:
- The email address doesn't exist
- The recipient's inbox was full
- Your previous emails to this address were marked as spam or rejected for another reason
Mailgun automatically adds bounced addresses to its "Suppressions" list to avoid wasting resources on undeliverable emails.
2. Check and Update Mailgun's Bounce List
First, let's fix the address block:
- Log into your Mailgun dashboard
- Navigate to Suppressions > Bounces
- Search for
ibrahim_hasan_eng@hotmail.com- If it shows up here, confirm the address is still valid (ask the recipient to double-check their email, inbox space, and spam folder)
- If the address is valid, click to remove it from the bounce list or temporarily disable the suppression for this address
3. Verify Your Laravel Mailgun Configuration
Let's make sure your Laravel setup is correct (since you mentioned following tutorials, double-check these):
- Open your
.envfile and confirm these values match your Mailgun details:MAIL_MAILER=mailgun MAILGUN_DOMAIN=syrianafood.dk MAILGUN_SECRET=your-mailgun-api-key-here MAIL_FROM_ADDRESS=postmaster@syrianafood.dk MAIL_FROM_NAME="${APP_NAME}" - Clear your config cache to ensure changes take effect:
php artisan config:clear
4. Test with a Different Email Address
Rule out configuration issues by testing with a working email you control (like a Gmail or personal domain address):
- Run
php artisan tinkerin your terminal, then paste this test code:Mail::raw('Test delivery from Laravel + Mailgun', function($message) { $message->to('your-test-email@example.com')->subject('Mailgun Test'); });
If this test email arrives, your Laravel-Mailgun setup is correct—the problem is isolated to the bounced hotmail address.
5. Long-Term Fixes for Bounce Handling
To avoid this in the future:
- Ask the recipient to add
postmaster@syrianafood.dkto their email whitelist and check their spam folder - Set up Mailgun webhooks in your Laravel app to automatically detect bounces and update user email statuses (so you don't keep trying to send to invalid addresses)
内容的提问来源于stack exchange,提问作者Ibrahim Hasan

