Finchy70
Finchy70

Reputation: 473

Laravel 5.5 and mailgun

I have been trying to send emails from my laravel app with mailgun but cant get it to work.

.env

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=(Default SMTP Login from mailgun)
MAIL_PASSWORD=**********
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS= hello@****.*****.me
MAIL_FROM_NAME= Me
MAILGUN_DOMAIN=*****.*****.me
MAILGUN_SECRET=key-10*****************************f

mail.php

return [
'driver' => env('MAIL_DRIVER', 'mailgun'),
'host' => env('MAIL_HOST', '*****.******.me'),
'port' => env('MAIL_PORT', 587),
'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'hello@*****.******.me'),
        'name' => env('MAIL_FROM_NAME', 'Me'),
'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
'username' => env('postmaster@*****.******.me'),
'password' => env('************'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
        'theme' => 'default',
        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],
];

services.php

'mailgun' => [
        'domain' => env('*****.******.me'),
        'secret' => env('key-1******************************f'),
    ],

Using this url to test

Route::get('/send_test_email', function(){
    Mail::raw('Sending emails with Mailgun and Laravel is easy!', function($message)
    {
        $message->to('[email protected]');
    });
});

No errors but no emails sent. Also no activity on my mailgun dashboard. All my mailgun DNS settings are verified for my domain.

Can anyone see what I'm doing wrong?

Upvotes: 1

Views: 1226

Answers (1)

joelrosenthal
joelrosenthal

Reputation: 501

Looks like you're using the value instead of the name in the config for username, password, domain, and secret. Should be

'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),

And

'mailgun' => [
        'domain' => env('MAILGUN_DOMAIN'),
        'secret' => env('MAILGUN_SECRET'),
],

Upvotes: 1

Related Questions