我在和Laravel设置邮件枪时遇到了麻烦。我一直收到以下消息:
ClientException in RequestException.php line 111:
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...)
不知道该怎么做。下面是我遵循的基本设置:
.env文件
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME='sandbox8e8c3965d4d14cac9d4f346c3d******'
MAIL_PASSWORD='e662ad1bbef5efd44cb96d32d6******'
MAIL_ENCRYPTION=tls
config/mail.php文件
'driver' => env('MAIL_DRIVER', 'mailgun'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => 'west**********@gmail.com',
'name' => 'My Name is here',
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
我的路由文件包含以下内容
Route::post('sendMail', function(\Illuminate\Mail\Mailer $mailer, \Illuminate\Http\Request $request) {
$title = $request->title;
$content = $request->content;
$mailer->to('westtexascentral@gmail.com')->send(new \App\Mail\MyMailer($title, $content));
return 'Mail sent.';
});
我的Mailer类包含以下内容:
public $title;
public $content;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($title, $content)
{
$this->title = $title;
$this->content = $content;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('kaley36_aw@yahoo.com')->view('emails.mail');
}
我希望我只是忽略了一些简单的东西,这有时是最难解决的事情,但任何帮助都会有所帮助。谢谢。
发布于 2016-11-10 19:49:44
如果你想使用邮件枪驱动程序(通过他们的应用程序接口使用邮件枪),你必须在config/services.php
上设置邮件枪的密码和域名
'mailgun' => [
'domain' => 'your-mailgun-domain',
'secret' => 'your-mailgun-key',
],
别忘了安装所需的Guzzle
包。打开终端并运行:
composer require guzzlehttp/guzzle
如果你通过应用程序接口使用邮件枪,只需确保在你的.env
文件中设置了这一行:
MAIL_DRIVER=mailgun
实际上,您可以忽略.env
文件中的以下指令。如果您使用的是SMTP协议,请使用以下代码:
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME='sandbox8e8c3965d4d14cac9d4f346c3d******'
MAIL_PASSWORD='e662ad1bbef5efd44cb96d32d6******'
MAIL_ENCRYPTION=tls
希望这对你有所帮助!
https://stackoverflow.com/questions/40534725
复制