vendredi 2 février 2018

Laravel Email, send multiples e-mails

I'm trying to send a mail to multiples providers, the problem is, I know that I can do this:

Mail::to($email['success'])->send($mail);

where $email['success'] is equals to:

0 => {
  'name' => 'Quimer Comercial Ltda.',
  'email' => 'anapaula.vendas@quimer.com.br'
},
1 => {
  'name' => 'Doce Aroma Industria e Comercio - 47'
  'email' => 'docearoma@docearoma.com.br'
},
2 => {
  'name' => 'Purifarma Distr.quimica e Farmac. Ltda.'
  'email' => 'purifarma@purifarma.com.br'
}

But this way, it shows all the e-mails to all the providers:

From: maxinutri@maxinutri.com.br
To: anapaula.vendas@quimer.com.br, docearoma@docearoma.com.br, purifarma@purifarma.com.br

I know too that I can use cc, but Laravel forces me to use to also, I could use the hack Mail::to([])->cc($email['success'])->send($mail);, but it will show this way

From: maxinutri@maxinutri.com.br
To: 

So I decided to send one, by one, this way:

$mail = new NewCotacao($codigoempresa, $codigocotacao);
foreach($emails['success'] as $email){
    Mail::to($email['email'])->send($mail);
}

But looks what is happening

enter image description here

I want to looks like this to each one

From:   maxinutri@maxinutri.com.br
To: anapaula.vendas@quimer.com.br



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire