Laravel will not transfer my domain to the MailGun driver, so I cannot send mail

This may not be a problem with MailGun, as I was unable to send it through Gmail.

The error I get, as shown below, you can see where the domain should be transferred, but it does not.

POST https://api.mailgun.net/v3//messages.mime 

domain must be

 POST https://api.mailgun.net/v3/domin/messages.mime 

I know that I have Guzzle installed, I retold the web server, and I know that my data is correct. I created a test project to do only mail, but to no avail.

Could this be something with my host computer (macbook air) or the fact that I am using a development web server

  php artisan serve 

I'm new to Laravel, so I don't know anything else I can do.

services.php

  'mailgun' => [ 'domain' => env('sandbox*****.mailgun.org'), 'secret' => env('key-**************'), ], 

Mail.php

 'driver' => env('MAIL_DRIVER', 'mailgun'), 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 'port' => env('MAIL_PORT', 587), 'from' => ['address' => null, 'name' => null], 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 'username' => env(' postmaster@sandbox ***********.mailgun.org'), 'password' => env('sandboxpassword'), 'sendmail' => '/usr/sbin/sendmail -bs', 'pretend' => env('MAIL_PRETEND', false), 

A've stopped using the env file, so it defaults to mail.php, but when the attributes have the same information, the same result. And yes, just ask him, I know that you need to restart the server when you change .env and just to be on a safe site, which I did when changing mail.php or services.php

Testcontroller.php

 <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Mail; use App\Http\Requests; use App\Http\Controllers\Controller; class TestController extends Controller { public function index() { Mail::raw('Text to e-mail', function ($message) { $message->from(' us@example.com ', 'Laravel'); $message->to(' dksnowdon@gmail.com '); }); return view('welcome'); } } 

exact mistake

 ClientException in RequestException.php line 107: Client error: `POST https://api.mailgun.net/v3//messages.mime` resulted in a `404 NOT FOUND` response: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>404 Not Found</title> <h1>Not Found</h1> <p>The requested (truncated...) in RequestException.php line 107 at RequestException::create(object(Request), object(Response)) in Middleware.php line 65 at Middleware::GuzzleHttp\{closure}(object(Response)) in Promise.php line 199 at Promise::callHandler('1', object(Response), array(object(Promise), object(Closure), null)) in Promise.php line 152 at Promise::GuzzleHttp\Promise\{closure}() in TaskQueue.php line 60 at TaskQueue->run(true) in Promise.php line 240 at Promise->invokeWaitFn() in Promise.php line 217 at Promise->waitIfPending() in Promise.php line 261 at Promise->invokeWaitList() in Promise.php line 219 at Promise->waitIfPending() in Promise.php line 62 at Promise->wait() in Client.php line 129 at Client->request('post', 'https://api.mailgun.net/v3//messages.mime', array('auth' => array('api', null), 'multipart' => array(array('name' => 'to', 'contents' => ' dksnowdon@gmail.com '), array('name' => 'message', 'contents' => 'Message-ID: < 9975c6b7d34f1fc93864bf7ff15f702a@localhost > Date: Wed, 09 Dec 2015 03:08:38 +0000 From: Laravel < us@example.com > To: dksnowdon@gmail.com MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Text to e-mail', 'filename' => 'message.mime')))) in Client.php line 87 at Client->__call('post', array('https://api.mailgun.net/v3//messages.mime', array('auth' => array('api', null), 'multipart' => array(array('name' => 'to', 'contents' => ' dksnowdon@gmail.com '), array('name' => 'message', 'contents' => 'Message-ID: < 9975c6b7d34f1fc93864bf7ff15f702a@localhost > Date: Wed, 09 Dec 2015 03:08:38 +0000 From: Laravel < us@example.com > To: dksnowdon@gmail.com MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Text to e-mail', 'filename' => 'message.mime'))))) in MailgunTransport.php line 79 at Client->post('https://api.mailgun.net/v3//messages.mime', array('auth' => array('api', null), 'multipart' => array(array('name' => 'to', 'contents' => ' dksnowdon@gmail.com '), array('name' => 'message', 'contents' => 'Message-ID: < 9975c6b7d34f1fc93864bf7ff15f702a@localhost > Date: Wed, 09 Dec 2015 03:08:38 +0000 From: Laravel < us@example.com > To: dksnowdon@gmail.com MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Text to e-mail', 'filename' => 'message.mime')))) in MailgunTransport.php line 79 at MailgunTransport->send(object(Swift_Message), array()) in Mailer.php line 85 at Swift_Mailer->send(object(Swift_Message), array()) in Mailer.php line 395 at Mailer->sendSwiftMessage(object(Swift_Message)) in Mailer.php line 181 at Mailer->send(array('raw' => 'Text to e-mail'), array(), object(Closure)) in Mailer.php line 133 at Mailer->raw('Text to e-mail', object(Closure)) in Facade.php line 219 at Facade::__callStatic('raw', array('Text to e-mail', object(Closure))) in TestController.php line 17 at Mail::raw('Text to e-mail', object(Closure)) in TestController.php line 17 at TestController->index() 
+7
php email laravel mailgun
source share
3 answers

You need to leave the services.php configuration as default:

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

Then in .env you need to put:

 MAILGUN_DOMAIN=yourdomain MAILGUN_SECRET=yoursecret 
+29
source share

Alternatively for kEpEx response you can remove the env () part from the services.php configuration

  'mailgun' => [ 'domain' => 'sandbox******.mailgun.org', 'secret' => 'key-****', ], 
+2
source share

If someone is struggling with this, after a while I find that my host is blocking all external mail servers.

They only allowed me to use their own mail servers. It might be worth checking if you really hit your head against a wall like me.

+2
source share

All Articles