参数#1($ mailable)必须是类型的Illuminate \ Contracts \ Contracts \ Mail \ Mailable,字符串给定
我尝试发送带有新创建帖子的电子邮件。但是我遇到了这个错误,但我不明白怎么了?
Illuminate \ Mail \ PendingMail :: send():参数#1($ mailable)必须是类型Illuminate \ Contracts \ Contracts \ Contracts \ Mail \ Mail \ mail \ crings,fess in/users/users/mattiasandersson/documents/utveckling/utveckling/tester/tester/event_listener/app/app/app/app/app/app/app/app/app/app/app/听众/notifypostCreated.php在第37行
public function handle(PostCreated $event)
{
$users = User::all();
foreach($users as $user) {
Mail::to($user->email)->send('emails.post_created', $event->post);
}
}
I try to send an email with a new created post. But I get this error, but I don't understand what is wrong?
Illuminate\Mail\PendingMail::send(): Argument #1 ($mailable) must be of type Illuminate\Contracts\Mail\Mailable, string given, called in /Users/mattiasandersson/Documents/Utveckling/TESTER/Event_Listener/app/Listeners/NotifyPostCreated.php on line 37
public function handle(PostCreated $event)
{
$users = User::all();
foreach($users as $user) {
Mail::to($user->email)->send('emails.post_created', $event->post);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
然后,在您的手柄方法上,您可以
注意:邮件:: to($ input ['email']) - > send($ postData); $ postdata是邮政运输类型,可扩展可邮寄。
希望这会有所帮助
Then on your handle method you can
Note:Mail::to($input['email'])->send($postdata); $postdata is of type PostMail which extends Mailable.
Hope this helps