I believe I have set up Mailgun quite correctly but am still getting 401 UNAUTHORIZED
from Laravel. Here's how I've done it:
In .env
:
MAIL_DRIVER=mailgun
MAILGUN_DOMAIN=mg.sample.domain
MAINGUN_SECRET=key-xxxxxxxxxxxxxxxxxxxxxxxx
In config/mail.php
:
'driver' => env('MAIL_DRIVER', 'smtp'),
When I send email, I get this error:
Client error: `POST https://api.mailgun.net/v3/mg.sample.domain/messages.mime` resulted in a `401 UNAUTHORIZED` response:
Forbidden
Are my details correct? Yes, because I was able to make it work using the command line:
curl -s --user 'api:key-xxxxxxxxxxxxxxxxxxx' https://api.mailgun.net/v3/mg.sample.domain/messages -F from='Excited User <user@sample.domain>' -F to=user@gmail.com -F subject='Hello' -F text='Testing some Mailgun awesomness!'
{
"id": "<20170311062047.101018.38081.E6E0ED9A@mg.sample.domain>",
"message": "Queued. Thank you."
}
One thing to note is the POST url used. The Mailgun docs say we should use /messages
, which is what I used from the command line, but Laravel is sending to /messages.mime
. Is something wrong here? When I try to POST to /messages.mime
from command line, I get:
{
"message": "'message' parameter is missing"
}
Any idea what's going on?
via dotslash