Php Laravel Mail::send返回零,在Mail::failures()中没有特定错误
我正在使用Php Laravel Mail::send返回零,在Mail::failures()中没有特定错误,php,laravel,email,laravel-5,Php,Laravel,Email,Laravel 5,我正在使用smtp驱动程序,这是我在laravel 5.2中发送电子邮件的代码: public function Sendmail() { $data["mail_message"] = "Hello!"; if(Mail::send('Emails.email', $data, function($message) { $message->from('webmaster@example.com', Input::get('name'));
smtp
驱动程序,这是我在laravel 5.2中发送电子邮件的代码:
public function Sendmail()
{
$data["mail_message"] = "Hello!";
if(Mail::send('Emails.email', $data, function($message)
{
$message->from('webmaster@example.com', Input::get('name'));
$message->to('amirhasan.hesam@gmail.com')->subject('Welcome to My Laravel app!');
}))
{
return "success";
}
else
{
return Mail::failures();
}
}
Mail::failures()
返回[”amirhasan。hesam@gmail.com“]
没有特定错误
这是我在mail.php上的配置:
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', '*******'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => "****@*****", 'name' => "Diling"],
'encryption' => env('MAIL_ENCRYPTION', ''),
'username' => env('*****@*****'),
'password' => env('*************************'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
我现在正在使用xamp测试电子邮件。有什么想法吗?我在mail::send中使用变量时遇到问题。。我也不确定mail::send是否返回布尔值之类的。。。我用了一些我过去写下的东西
$nameSend = Input::get('name');
Mail::send('Emails.email', $data, function($message) use ($nameSend){
$message->from('webmaster@example.com', $nameSend);
$message->to('amirhasan.hesam@gmail.com')->subject('Welcome to My Laravel app!');
});
。
您只需要使用Mail facade
use Illuminate\Support\Facades\Mail;
我认为问题不在于输入类型!事实上,
Mail::send
如果发送成功,则应发送1;如果发送失败,则应发送0。在我的例子中,它返回0,对于Mail::failures()
和您的代码,它返回:有一个或多个失败。他们是:阿米拉桑。hesam@gmail.com
实际上,我真的需要知道它为什么会失败!!你查过laravel日志了吗?有时,由于连接到SMTP时出错,电子邮件发送失败。您的日志文件中有什么内容?它们在这个目录/project/storage/logs/中,甚至我也有同样的问题。laravel日志中没有错误,Mail::failures()只返回我们发送电子邮件的邮件ID。
use Illuminate\Support\Facades\Mail;