【发布时间】:2015-02-02 20:47:16
【问题描述】:
您好,我一直只是尝试在 laravel 中发送电子邮件,我阅读了文档,他们让它看起来很容易,但是每当我尝试时,我不断收到错误,我尝试 sendgrid 没有工作,现在我尝试使用 mailgun,但我也遇到了问题。
这是我的代码::
$data = array();
Mail::send('emails.auth.activate', $data, function($message)
{
$message->to('xxxxxxxxx@gmail.com', 'John Doe')->subject('This is a demo!');
});
这是我得到的错误:
GuzzleHttp \ Exception \ ClientException (400)
Client error response [url] https://api.mailgun.net/v2/mail.xxxxxxx.com/messages.mime [status code] 400 [reason phrase] BAD REQUEST
邮件配置:
<?php
return array(
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log"
|
*/
'driver' => 'mailgun',
'host' => 'sandboxXXXXXXXXXXXXXXXXXXXXXXXXXXX.mailgun.org',
'port' => 587,
'from' => array('address' => 'mail@xxxxxx.com', 'name' => 'Xxxxxxxx'),
'encryption' => 'tls',
'username' => 'xxxxxxx@gmail.com',
'password' => 'xxxxxxxxxxx',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => true,
);
【问题讨论】:
-
您能否提供有关您当前邮件配置的更多信息,以及您在哪里实例化 emails.auth.activate?
-
实例化是什么意思?我认为这应该是通往视图的路径。
-
我只是向我们展示了更多代码,例如您的 mailgun 设置在哪里,您在任何库中加载的位置,您从哪里获取配置设置。