-2
In this "Laravel PHP" email sending script I loop for multiple sending.
The problem is that I’m not finding the solution to pass the variables "$email" of posts to within the function "Function($m)"
I’m only able to pass this way "define('EMAIL', $email);" but in the loop it error What’s the best way to do that?
public function disparo_em_massa(Request $campos) //contato
{
foreach ($campos['id'] as $key => $value) {
$contato = $_POST['contato'][$key];//
$email = $_POST['email'][$key];//
$id = $_POST['id'][$key];//
define('EMAIL', $email);
Mail::send('emails.recadatro_mail',[
'id' =>$id ,
'nome' => $contato ,
'email' =>$email ],
function($m) {
echo $email = EMAIL;
$m->from('[email protected]', 'Triplxx Receptivo');
$m->to("$email");
$m->returnPath('[email protected]');
$m->subject('Atualização Cadastral');
$m->getHeaders()->addTextHeader('X-Confirm-Reading-To: [email protected]');
});
}
}
Dude, you’re mixing Windows with raw php, the Windows has features need to access the
$_POST
directly. TheMail
can also be sent to multiple emails at once without needing to perform foreach.– Jedson Melo