Encountering problems sending welcome emails with token verification using Laravel and Mailgun. The sender address isn’t accepted. See the revised code below:
namespace App\Mail;
use Illuminate\Mail\Mailable;
class VerifyTokenMail extends Mailable {
protected $token;
public function __construct($token) {
$this->token = $token;
}
public function build() {
return $this->from('[email protected]')
->subject('Confirm Your Registration')
->view('emails.verify', ['token' => $this->token]);
}
}
hey, try clearing laravel cache and double-check that sender adress in .env matches the one in your mailable. mailgun can act strnge if they dont align. hope that helps!
It appears the issue might not solely reside in Laravel but in how Mailgun is set up for your sending domain. I resolved a similar problem by verifying that the domain configured in Mailgun matches the one used in the code. Although I use a different email for the from() method, I ensured that this domain is fully authenticated on Mailgun’s end. I also encountered errors due to misconfigured API keys, so double-checking these credentials and reviewing Mailgun’s logs for failures helped pinpoint the issue.
I experienced a similar issue last month while setting up welcome emails with Laravel and Mailgun. My problem was eventually traced to a mismatch between the sender email and the verified domain on my Mailgun account. Indeed, it is crucial that the sender address used in the build method is fully authorized in your Mailgun settings. I solved this by rechecking both my Mailgun domain configuration and the credentials in Laravel. It might also help to review Mailgun’s logs to identify any authentication issues that could be causing the delivery errors.