Server: Digital Ocean
Ubuntu 16.04
Laravel 5.8
I cannot get email to send out of laravel using mailgun.com
In Digital Ocean I have all outgoing ports open on the firewall, I have the correct DNS settings in Digital ocean for TXT and MX records. I have the correct and verified DNS records on my domain registar and mailgun has a green checkmark on all
config/mail.php
return [
'driver' => 'mailgun',
'host' => 'smtp.mailgun.org',
'port' => 587,
'from' => [
'address' => '[email protected]',
'name' => 'Company Name'
],
'encryption' => 'tls'),
'username' => '[email protected]',
'password' => 'xxxxd663hd02j727bb2eefd1ea38bbe0-58bc211a-670xxxx'
];
config/services.php
'mailgun' => [
'domain' => 'https://api.mailgun.net/v3/mg.domain.com',
'secret' => 'xxxxehbe8v25g3374e5as3ff32a45995-39bc661a-4716xxxx',
],
Controller
use Illuminate\Support\Facades\Mail;
$data = [
'email' => '[email protected]',
'name' => 'Bob Smith'
];
$body_data = [
'id' => '1234'
];
Mail::send('emails.shipped', $body_data, function($message) use ($data)
{
$message->to($data['email'], $data['name'])->subject('Test Email');
});
When I change mail driver to log and then check log file it looks great. Everything looks perfect and I have used mailgun before on Laravel 5.5 with no problems. I have also tried the new laravel build method and same issue.
I get no errors, I checked logs on apache2, no logs are appearing in mailgun and of course no email comes through in inbox or spam.
My question is, am I missing anything? What other troubleshooting can I do? Seems like my app isn't connecting to mailgun correctly.
Send via API Run this: curl -s --user 'api:YOUR_API_KEY' \ https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages \ -F from='Excited User <mailgun@YOUR_DOMAIN_NAME>' \ -F to=YOU@YOUR_DOMAIN_NAME \ -F [email protected] \ -F subject='Hello' \ -F text='Testing some Mailgun awesomeness!
I think that in your config/services.php
the mailgun.domain should be more like
mg.domain.com
(or sandboxXXXXXXX.mailgun.org
if that's a dev environment), and not a url like the one you've set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With