I am doing a generated order, and when this is correct send an email to the client with acknowledgments and the corresponding invoice. But you would need that at the same time send an email to another address that would be the administration so that they know that they have received a new order. Of course, the message must be different.
This is how I have it now:
$html = ob_get_contents();
ob_end_clean();
$html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
//$html = str_replace("�", "Á", $html);
require_once 'dompdf/autoload.inc.php';
use Dompdf\Dompdf;
$dompdf = new DOMPDF();
$dompdf->setPaper('A4', 'portrait');
$dompdf->loadHtml($html);
ini_set("memory_limit","64M");
$dompdf->render();
$pdf = $dompdf->output();
file_put_contents("facturas/".$facturaid.".pdf", $pdf);
/* ENVIO DE PDF POR CORREO ELECTRÓNICO */
include "plantillaEmail/templatePedido.php";
include "PHPMailer/class.phpmailer.php";
include "PHPMailer/class.smtp.php";
$email_user = "[email protected]";
$email_password = "pass";
$the_subject = "Factura " . $facturaid;
$address_to = $usuariosArray['Username'];
$from_name = "Depildiodo";
$phpmailer = new PHPMailer();
// ---------- datos de la cuenta de Gmail -------------------------------
$phpmailer->Username = $email_user;
$phpmailer->Password = $email_password;
//-----------------------------------------------------------------------
// $phpmailer->SMTPDebug = 1;
$phpmailer->CharSet = 'UTF-8';
$phpmailer->SMTPSecure = 'ssl';
$phpmailer->Host = "mail.depildiodo.com"; // GMail
$phpmailer->Port = 465;
$phpmailer->IsSMTP(); // use SMTP
$phpmailer->SMTPAuth = true;
$phpmailer->setFrom($phpmailer->Username,$from_name);
$phpmailer->AddAddress($address_to); // recipients email
$phpmailer->Subject = $the_subject;
$phpmailer->Body = $body;
$phpmailer->AddAttachment("facturas/".$facturaid.".pdf",
$facturaid.".pdf");
$phpmailer->IsHTML(true);
$phpmailer->Send();
$_SESSION['carrito']= array();
if($redireccion != ""){
header('Location: '.$redireccion, true, 301);
}else {
header('Location: index.php', true, 301);
}
Any suggestions please?