Level 88
Take a look at your .env variables, you need to set a username and password provided by mailgun.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hello everybody, today i try to test mailgun laravel on my hosting and i get 1 error
ClientException in Middleware.php line 69:
Client error: 400
This is first time i using mailgun, before i used smtp gmail and send okey
Anyone can help us find the cause.
My configs:
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
return [
'mailgun' => [
'domain' => 'sandboxe################.mailgun.org',
'secret' => 'key-################',
],
...............
]
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => '######@gmail.com', 'name' => 'Admin'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
Route::get('sendemail', function () {
Mail::send('emails.master', [], function ($message) {
$message->to('#######@gmail.com')->subject('Learning Laravel test email');
});
return "Your email has been sent successfully";
});
Please or to participate in this conversation.