Php Laravel 7x API不发送邮件警报
当我试图与邮递员或失眠症,使邮政存储与数据的电子邮件没有到达我不明白为什么 我有以下字段:Php Laravel 7x API不发送邮件警报,php,laravel,api,model-view-controller,alert,Php,Laravel,Api,Model View Controller,Alert,当我试图与邮递员或失眠症,使邮政存储与数据的电子邮件没有到达我不明白为什么 我有以下字段: public function up() { Schema::create('polls', function (Blueprint $table) { $table->id(); $table->text('now'); $table->json('p
public function up()
{
Schema::create('polls', function (Blueprint $table) {
$table->id();
$table->text('now');
$table->json('paramJson');
$table->enum('status', ['a', 'b', 'c','d'])->default('a');
});
}
投票模式:
protected $fillable = ['now'];
protected $casts = ['paramJson' => 'array'];
PollsController.php
public function store(Request $request)
{
$poll = request->all();
if($poll['status']=='b')
{
Mail::to('example@....com')->send(new NotifyPoll($poll));
}
return response()->json(Poll::create($poll), 201);
}
邮件/通知投票
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class NotifyPoll extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data)
{
$this->itemPoll = $data;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('.......@inbox.mailtrap.io')->subject('Error Poll')->view('mail.notifyErrorPoll',['mail_data'=>$this->itemPoll]);
}
}
我没有收到错误,但不幸的是邮件没有到达。我认为您错过了
NotifyPoll
类中的protected$itemPoll
。另外,检查日志文件以获取错误堆栈。它在调试时帮助很大。我认为您错过了NotifyPoll
类中的protected$itemPoll
。另外,检查日志文件以获取错误堆栈。它在调试时非常有用。您是否尝试过将投票数据作为Mailable
类的公共属性<代码>公共$poll然后使用\u construct($poll)
以便模板可以使用它?您是否尝试过在Mailable
类中将轮询数据设置为公共属性<代码>公共$poll然后使用\u构造($poll)
以便模板可以使用它?我想我不明白您的意思:“我想您在NotifyPoll中遗漏了受保护的$itemPoll”。在哪里可以找到日志文件?@Gianmarco Gagliardi您没有在类中声明$itemPoll
变量。日志文件可以在storage/logsok I should do public$itemPoll中找到。我不明白这是干什么用的?。我的问题与配置端ENV senderI有关,我想我不明白您的意思:“我认为您在NotifyPoll中遗漏了受保护的$itemPoll”。在哪里可以找到日志文件?@Gianmarco Gagliardi您没有在类中声明$itemPoll
变量。日志文件可以在storage/logsok I should do public$itemPoll中找到。我不明白这是干什么用的?。我的问题与配置端环境发送器有关