gpt4 book ai didi

php - Laravel 不会将我的域传递给 MailGun 驱动程序,所以我无法发送邮件

转载 作者:可可西里 更新时间:2023-11-01 12:40:47 25 4
gpt4 key购买 nike

这可能不是 MailGun 的问题,因为我也无法通过 Gmail 发送。

我收到的错误如下所示,您可以看到域应该传递但没有传递的位置。

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

域名应该是

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

我知道我安装了 Guzzle,我已经重述了网络服务器,我知道我的详细信息是正确的。我已经创建了一个测试项目来仅发送邮件,但无济于事。

这可能与我的主机(macbook air)有关,还是我正在使用开发网络服务器?

 php artisan serve

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

服务.php

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

邮件.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 时一直这样做

测试 Controller .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', 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()

最佳答案

您需要将 services.php 配置保留为默认配置:

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

然后在 .env 中你需要放:

MAILGUN_DOMAIN=yourdomain
MAILGUN_SECRET=yoursecret

关于php - Laravel 不会将我的域传递给 MailGun 驱动程序,所以我无法发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34169038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com