I have a website with an email form response. I need to send 2 emails when clicked and is working with slim framework, msgHTML and twig. I set twig template by a condition to show one part of that template for the first email and other part for the another. Don't work because the first email body message was added to the second one.
So I created 2 instances of phpmailer to send 2 separate twig templates but the same error appears, it add the 2 templates in the last email body message.
Is there a way to unset the msgHTML message or the view?
$mailu = new PHPMailer; $maila = new PHPMailer;
$mailu->isHTML(true); $maila->isHTML(true);
$mailu->isSMTP(); $maila->isSMTP();
$mailu->Host = 'XXX'; $maila->Host = 'XXX';
$mailu->Port = 587; $maila->Port = 587;
$mailu->SMTPAuth = true; $maila->SMTPAuth = true;
$mailu->SMTPSecure = 'tls'; $maila->SMTPSecure = 'tls';
$mailu->Username = 'XXX; $maila->Username = 'XXX';
$mailu->Password = 'XXX'; $maila->Password = 'XXX';
$mailu->SMTPDebug = 0; $maila->SMTPDebug = 0;
$mailu->setLanguage('es'); $maila->setLanguage('es');
$mailu->CharSet="utf-8"; $maila->CharSet="utf-8";
$mailu->clearCustomHeaders(); $maila->clearCustomHeaders();
$mailu->Subject = $subject; $maila->Subject = $subject;
$marrayu = array('user'=>true, 'name'=>$name, 'email'=>$email, 'subject'=>$subject, 'message'=>$message, 'phone'=>$phone);
$mailu->msgHTML($this->view->render($response, 'templates/mailu.twig', array( "marray" => $marrayu )));
$mailu->setFrom($domainmail, 'NMV');
$mailu->addAddress($email, $name);
$mailu->addReplyTo($domainmail, 'NMV');
$mailu->send();
$marraya = array('user'=>false, 'name'=>$name, 'email'=>$email, 'subject'=>$subject, 'message'=>$message, 'phone'=>$phone);
$maila->msgHTML($this->view->render($response, 'templates/maila.twig', array( "marray" => $marraya )));
$maila->setFrom($email, $name);
$maila->addAddress($domainmail,'NMV');
$maila->send();
return $this->response->withStatus(200)->withHeader('Location', $anchor);
Any suggestions?