gpt4 book ai didi

php - 发送邮件到用户电子邮件地址 - Laravel 5.4

转载 作者:行者123 更新时间:2023-12-01 20:26:16 25 4
gpt4 key购买 nike

我想向刚刚输入电子邮件地址的用户发送一封电子邮件。

像这样,

$email = $request->email;

Mail::send('emails.info', $data, function ($message) {

$message->from('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1974607c74787075597e74787075377a7674" rel="noreferrer noopener nofollow">[email protected]</a>', 'My Email');

$message->to($email)->subject('The subject');

});

但这会返回一个错误:

Undefined variable: email

问题出在哪里?

最佳答案

您需要在关闭使用中引用电子邮件 use

$email = $request->email;

Mail::send('emails.info', $data, function ($message) use ($email) {

$message->from('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3e53475b535f57527e59535f5752105d5153" rel="noreferrer noopener nofollow">[email protected]</a>', 'My Email');

$message->to($email)->subject('The subject');

});

关于php - 发送邮件到用户电子邮件地址 - Laravel 5.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43221958/

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