Laravel 邮件 - 如何调试 Mailgun

Laravel mail - how to debug Mailgun

我正在尝试使用 laravel (5.3) 设置 mailgun,但 returns 为空,不显示错误也不发送电子邮件。我还用 PHP CURL 尝试了这个 mailgun 参数,它也能正常工作。我还设置了 MAIL_DRIVER=log 其工作。我如何调试 Laravel Mailgun?

我已经安装了 Guzzle。

我没有安装Laravel队列系统。会不会是因为这个问题?

我的日志:

    [2019-08-06 13:19:04] local.DEBUG: Message-ID: 
    <21f27....9cf293be62@todo.test>
    Date: Tue, 06 Aug 2019 13:19:04 +0000
    Subject: Activate Your Account
    From: s....@gmail.com
    To: s....@gmail.com
    MIME-Version: 1.0
    Content-Type: text/html; charset=utf-8
    Content-Transfer-Encoding: quoted-printable

    <h2>this is test mail</h2>
    <p>Lorem ipsum dolor sit amet, consectetur</p>

我的 .env 参数

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=2525 //tried other ports 25, 587, and 465
MAIL_USERNAME=postmaster@sandbox5....a6df0f425dfd0.mailgun.org
MAIL_PASSWORD=f6ae0....b4e0a8205b-73ae490d-d2e10d3d
MAIL_ENCRYPTION=TLS
MAILGUN_DOMAIN=sandbox.....f0f425dfd0.mailgun.org
MAILGUN_SECRET=56cc50b....10c62e08-73ae490d-11f1b30a
MAIL_FROM_ADDRESS=postmaster@sandb....df0f425dfd0.mailgun.org
MAIL_FROM_NAME=ToDo

我的控制器

Mail::to('m....r@gmail.com')->send(new SendMail());

if(count(Mail::failures()) > 0){
    return 'Failed to send password reset email, please try again.';
}

我的邮箱class

    public function build()
        {
            return $this->from('postmaster@san....0f425dfd0.mailgun.org')
                ->subject('Activate Your Account')
                ->view('emails.test');
        }

我在 config/services.php

中发现问题
'mailgun' => [
    'domain' => 'https://api.mailgun.net/v3/sandbox53bb3c32cee7449f961a6df0f425dfd0.mailgun.org',
    'secret' => '56cc50bafb9320f2ef3c9d3210c62e08-73ae490d-11f1b30a',
],

改为

'mailgun' => [
    'domain' => 'sandbox53bb3c32cee7449f961a6df0f425dfd0.mailgun.org',
    'secret' => '56cc50bafb9320f2ef3c9d3210c62e08-73ae490d-11f1b30a',
],

然后returns

Client error: `POST https://api.mailgun.net/v3/dfd0.mailgun.org/messages.mime` resulted in a `400 BAD REQUEST` response:
{
"message": "Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authoriz (truncated...)

最终 mailgun API 起作用了