php - Mail::send Laravel 中的语法错误

标签 php laravel swiftmailer

我不知道为什么我不断收到这个简单的错误。错误是说我不应该在该行上有 ;

syntax error, unexpected ';'

使用下面的代码我没有收到任何错误:

Mail::send('emails.invite.invite',$user, function ($message) use ($email) {
    $message->subject('Message Subject');
    $message->from('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="650b0a170015091c25001d04081509004b0b0011" rel="noreferrer noopener nofollow">[email protected]</a>', 'Sender Name');
    $message->to($email); // Recipient address
});

但是当我添加数组时,我收到错误:

Mail::send('emails.invite.invite', array('link' => URL::route('account-activate', $code), $user, function ($message) use ($email) {
    $message->subject('Message Subject');
    $message->from('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bbd5d4c9decbd7c2fbdec3dad6cbd7de95d5decf" rel="noreferrer noopener nofollow">[email protected]</a>', 'Sender Name');
    $message->to($email); // Recipient address
}); 

最佳答案

if($user) {
             Mail::send('emails.invite.invite', array('link' => URL::route('account-activate', $code),'name' => $name), function ($message) use ($email) {
                $message->subject('Message Subject');
                $message->from('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a8c6c7dacdd8c4d1e8cdd0c9c5d8c4cd86c6cddc" rel="noreferrer noopener nofollow">[email protected]</a>', 'Sender Name');
                $message->to($email); // Recipient address
            });

关于php - Mail::send Laravel 中的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24944748/

相关文章:

PHP - 为什么使用 Guzzle 而不是 cURL?

javascript - 尝试通过 AJAX 发送输入文件数据,无法访问我的 Controller 中的数据

php - swiftmailer 假脱机文件路径

symfony - 配置 Symfony2/Swiftmailer 使用 "sendmail -t"

html - 使用 Swift Mailer 将 html 和 css 邮件发送到 gmail

php - 如何使用同名的多个复选框自定义查询字符串?

php - 在 C 中使用 http 设置 PHP super 全局变量

javascript - Laravel,将变量从 Controller 传递到 js 时的不同输出

php - Paypal REST Api 实现

php - 解释正则表达式/^[a-zA-Z ]*/