【问题标题】:Laravel Mail::send() Send Multiple mails with to and cc addressesLaravel Mail::send() 使用 to 和 cc 地址发送多封邮件
【发布时间】:2017-10-18 03:36:09
【问题描述】:

我是Laravel 的新手。 我的目标是使用Mail::send()tocc 发送多封邮件

我一直在从.env 文件中检索我存储的电子邮件:

toEmails='one@domain.ext','two@domain.ext'

controller 检索电子邮件并使用以下代码发送:

$toEmails = env('toEmails');

$message->to(toEmails); OR $message->cc(toEmails);

以下代码不断出现错误:

MailboxHeader.php 第 345 行中的 Swift_RfcComplianceException: 给定邮箱中的地址 [[email protected],[email protected]] 不符合 RFC 2822, 3.6.2。

我一直在尝试以下对我不起作用的代码。 在.env文件中

toEmails=array('one@domain.ext','two@domain.ext'),
toEmails=one@domain.ext,two@domain.ext'

我怎样才能从中恢复。

【问题讨论】:

    标签: php laravel email


    【解决方案1】:

    您不能在 .env 文件中设置数组。但是 mail 方法使用数组来发送电子邮件。因此,请使用逗号分隔的电子邮件列表,然后将它们转换为控制器中的数组。

    // .env file
    toEmails=one@domain.ext,two@domain.ext
    
    // controller
    $emails = explode(',', env('toEmails'));
    

    【讨论】:

      猜你喜欢
      • 2014-12-22
      • 2017-06-05
      • 2020-10-30
      • 1970-01-01
      • 1970-01-01
      • 2010-12-05
      • 1970-01-01
      相关资源
      最近更新 更多