Reputation: 1285
I am trying to send mails to multiple recipients,But i got an error like
Swift_RfcComplianceException in MailboxHeader.php line 345: Address in mailbox given [[email protected], [email protected], [email protected]] does not comply with RFC 2822, 3.6.2.
but the code does however work when I only specify one recipient.
Here is my code:
Controller :
$myEmail='[email protected], [email protected]';
$dataArray['name'] ='name';
$dataArray['E_id'] = 011;
$dataArray['password'] = '1234';
$dataArray['username'] = 'test';
Mail::to($myEmail)->send(new HeadMail($dataArray));
HeadMail.php(inside app folder)
public function build() {
$address = '[email protected]';
$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'],
]);
}
How can I send the email to all recipients?Please help me.
Upvotes: 3
Views: 2296
Reputation: 8030
Separate emails with a comma and use a simpler solution. At least, this is what I do:
Mail::send(['blade.view.html', 'blade.view.txt'], ['title' => $subject, 'content' => $content], function ($message) {
$message->from('[email protected]', 'IT Serviss');
$message->to(explode(",", $client_email_array));
$message->subject($subject);
});
Upvotes: 1