How do I get all the img
with the foreach and send for email
, I put my function to send the email
inside the loop but it will not send me only the first one and if I put the function out of the loop he sends me the last one could help me?
code
if(!empty($_POST)){
foreach($_POST['ck'] as $ck){
$msg = "<img src=\"http://www.site.com.br/images/$ck\"width=\"100px\" height=\"70px\"><br>";
// manda e-mail usuario
$mail = new PHPMailer();
$mail-> IsSMTP();
$mail->CharSet = "UTF-8";
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->Host = "smtp.zoho.com";
$mail->Username = "[email protected]";
$mail->Password = "senha";
$mail->SetFrom("[email protected]", "usuario");
$mail->AddAddress("[email protected]", "usuario");
$mail->Subject = "assunto";
$mail->msgHTML($msg);
if($mail->send()){
echo "enviado com sucesso";
exit();
}else{
echo "Erro ao enviar o email".$mail->ErrorInfo;
}
}
}