我在使用 Laravel 设置 Mailgun 时遇到问题。我不断收到以下消息:
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');
}
我希望我只是看起来很简单,这有时是最难解决的问题,但任何帮助都会有所帮助。谢谢你。