php – Laravel不会将我的域名传递给MailGun驱动程序,因此我无法发送邮件

前端之家收集整理的这篇文章主要介绍了php – Laravel不会将我的域名传递给MailGun驱动程序,因此我无法发送邮件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这可能不是MailGun的问题,因为我无法通过Gmail发送.

我在下面看到的错误你可以看到域应该通过的地方但没有.

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

域名应该是

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

我知道我安装了Guzzle,我重新安装了Web服务器,我知道我的详细信息是正确的.我创建了一个测试项目,只做邮件,但无济于事.

可能是我的主机(macbook air)或我正在使用开发Web服务器的东西

PHP artisan serve

我是Laravel的新手,所以我不确定我能做些什么.

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已经停止使用env文件,因此它默认为mail.PHP,但是当属性是相同的细节时,结果是相同的.是的,只是因为我知道你需要重新启动服务器,当你改变了.env并且只是为了安全网站我一直在改变mail.PHP或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');
    }
}

确切的错误

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','filename' => 'message.mime'))))) in MailgunTransport.PHP line 79
at Client->post('https://api.mailgun.net/v3//messages.mime','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()
您需要将services.PHP配置保留为默认值:
'mailgun' => [
        'domain' => env('MAILGUN_DOMAIN'),'secret' => env('MAILGUN_SECRET'),

然后在.env中你需要放:

MAILGUN_DOMAIN=yourdomain
MAILGUN_SECRET=yoursecret
原文链接:https://www.f2er.com/laravel/137069.html

猜你在找的Laravel相关文章