Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nanadjei2's avatar

Mailgun not able to send email

I want guest users to send me feedbacks on my website. I used mailgun's api but I keep getting this error anytime I try to send mails. Client error:POST https://api.mailgun.net/v3//messages.mimeresulted in a404 NOT FOUND` response:

404 Not Found

Not Found

The requested (truncated...)`

This is my mail.php

  return [
 'driver' => env('MAIL_DRIVER'),
 'host' => env('MAIL_HOST'),
'port' => 587,
'from' => ['address' => '', 'name' => ''],
'encryption' => env('MAIL_ENCRYPTION'),
'username' => env('MAIL_USERNAME'),
'password' => env(MAIL_PASSWORD),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => env('MAIL_PRETEND', false),

];

This is my .env

    MAIL_DRIVER=mailgun
    MAIL_DOMAIN=sand*****************.mailgun.org
    MAIL_HOST=smtp.mailgun.org
    MAIL_PORT=587
    [email protected]
    MAIL_PASSWORD=*************
    MAIL_SECRET=key-*************************
    MAIL_ENCRYPTION=tls

Service.php

    'mailgun' => [
   'domain' => env('MAILGUN_DOMAIN'),
   'secret' => env('MAILGUN_SECRET'),
  ],
   
0 likes
8 replies
ejdelmonico's avatar

Well, their is a wrapper in laravel so I use just my domain like sandbox39495858577585.mailgun.org for the MAILGUN_DOMAIN and your MAIL_USERNAME should be something like postmaster@ sandbox39495858577585.mailgun.org. Mailgun gives you this info on their site. Your mail from info comes from config/mail.php...whatever you have in there.

1 like
ejdelmonico's avatar

Alright, let's make sure we are on the same page. You are using the domain info provided by mailgun for the sandbox. "default SMTP Login" is your MAIL_USERNAME. "default password" is your MAIL_PASSWORD, "API Key" is your MAILGUN_SECRET and MAILGUN_DOMAIN is the "API Base URL" after the "v3/". Also, which version of Laravel are you using? And, that error message is saying you need to verify your DNS so something is off. Also, you are only allowed five recipients and you are supposed to register them on the site.

nanadjei2's avatar

all the configurations are right. Am using laravel 5.1. Or is it because i am having this error Your account is temporarily disabled. Business Verification Please contact support to resolve on my mailgun account? I think it is because of that error and if so, how do i fix it?

nanadjei2's avatar
nanadjei2
OP
Best Answer
Level 4

I intended to use gmail instead. I had a few problems with it but instead of setting the driver to smtp, i made it sendmail. and it worked.

aquintero's avatar

I know is a long time ago but i think the problem is you need to add the receipt email address to authorized recipients on the mailgun panel, otherwise you can't sent email to this address, this apply for the free account.

rohit0403's avatar

Make sure to check your credentials for the mailgun, make sure that those are correct.

Dont copy the Public Validation Key. please copy the Private API Key

Please or to participate in this conversation.