我正在尝试向多个收件人发送邮件,但我收到了类似
的错误MailboxHeader.php第345行中的Swift_RfcComplianceException:地址 给出的邮箱[exmple1@gmail.com,example2 @ gmail.com, ex3@gmail.com]不符合RFC 2822,3.6.2。
但是当我只指定一个收件人时,代码确实有效。
这是我的代码:
控制器:
$myEmail='exmple1@gmail.com, exmple2@gmail.com';
$dataArray['name'] ='name';
$dataArray['E_id'] = 011;
$dataArray['password'] = '1234';
$dataArray['username'] = 'test';
Mail::to($myEmail)->send(new HeadMail($dataArray));
HeadMail.php(在app文件夹中)
public function build() {
$address = 'abc@gmail.com';
$name = 'test TEAM';
$subject = 'USER CREDENTIALS';
return $this->view('emails.index')
->from($address, $name)
->cc($address, $name)
->bcc($address, $name)
->replyTo($address, $name)
->subject($subject)
->with([
'name' => $this->dataArray['name'],
'password' => $this->dataArray['password'],
'E_id' => $this->dataArray['E_id'],
'email' => $this->dataArray['username'],
]);
}
如何将电子邮件发送给所有收件人?请帮助我。
答案 0 :(得分:0)
使用逗号分隔电子邮件并使用更简单的解决方案。至少,这就是我的工作:
Mail::send(['blade.view.html', 'blade.view.txt'], ['title' => $subject, 'content' => $content], function ($message) {
$message->from('it@example.com', 'IT Serviss');
$message->to(explode(",", $client_email_array));
$message->subject($subject);
});