Laravel 5.3 通知 - 仅使用电子邮件地址通知

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43047966/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 15:39:47  来源:igfitidea点击:

Laravel 5.3 Notification - notify using only email address

laravelnotifications

提问by lewis4u

I have an input field in my app for external email and i want to send a Notification on that email.

我的应用程序中有一个用于外部电子邮件的输入字段,我想在该电子邮件上发送通知。

The problem is that this email can be outside of my app so i can't use $user->notify().

问题是这封电子邮件可能在我的应用程序之外,所以我不能使用 $user->notify()。

Is there a way to send a notification using only email address??

有没有办法只使用电子邮件地址发送通知?

回答by Conrad Warhol

With Laravel 5.5 and above you can send "On Demand Notifications" using the Notificationfacade:

在 Laravel 5.5 及更高版本中,您可以使用Notification门面发送“按需通知” :

Notification::route('mail', '[email protected]')->notify(new InvoicePaid($invoice));

Topic on Official Docs

官方文档主题

回答by Conrad Warhol

You can easily create a temporary User instance with the email address.

您可以使用电子邮件地址轻松创建临时 User 实例。

(new User)->forceFill([
    'name' => 'Their name',
    'email' => '[email protected]',
])->notify(new MailMessage);