gpt4 book ai didi

php - Laravel:在 Mail::to 中使用电子邮件和姓名

转载 作者:可可西里 更新时间:2023-11-01 13:37:32 26 4
gpt4 key购买 nike

我有一个联系表,其中有人提供了他的姓名和电子邮件。我现在想用 Laravel 给他发一封电子邮件。

我在 docs 中找到

To send a message, use the to method on the Mail facade. The to method accepts an email address, a user instance, or a collection of users.

事实上

\Mail::to('example@gmail.com')->send(new \App\Mail\Hello);

有效。但是是否也可以提供电子邮件收据的姓名

我想在 Laravel API 中查找 Mail Facade但令我惊讶的是,立面没有to功能?

那么我怎样才能知道 to 函数的真正作用,以及我是否也可以传递名称参数?

最佳答案

在 laravel 5.6 中,您的问题的答案是:为每个具有“电子邮件”和“姓名”键的收件人使用关联数组,应该与 $to、$cc、$bcc 一起使用

$to = [
[
'email' => $email,
'name' => $name,
]
];
\Mail::to($to)->send(new \App\Mail\Hello);

关于php - Laravel:在 Mail::to 中使用电子邮件和姓名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47905130/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com