<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require'Exception.php';
require'PHPMailer.php';
require'SMTP.php';


if (isset($_POST['fileDataURI'])) {

$pdfdoc = $_POST['fileDataURI'];
$Email = $_POST['Email'];
$Condominio = $_POST['Condominio'];
$Mesano = $_POST['Mesano'];

$b64file = trim( str_replace( 'data:application/pdf;base64,', '', $pdfdoc ) );
$b64file = str_replace( ' ', '+', $b64file );
$decoded_pdf = base64_decode( $b64file );
//file_put_contents( $attachment, $decoded_pdf );

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->Host = "intelpropertyrd.com";
$mail->Port = "465"; // 8025, 587 and 25 can also be used. Use Port 465 for SSL.
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Username = "entrenamiento@intelpropertyrd.com";
$mail->Password = "(Made7474)";

$mail = new PHPMailer;
$mail->setFrom( 'adm@intelpropertyrd.com', 'Sistema de Administracion' );
$mail->addAddress( $Email, 'Usuario' );
$mail->Subject  = 'Reporte de Pagos Pendientes';
$mail->Body     = 'Reporte de Pagos pendientes correspondiente al residencial '.$Condominio.'';
$mail->addStringAttachment($decoded_pdf, "Reporte de Pagos Pendientes.pdf");
$mail->isHTML( true );
$mail->send();

}

?>