I have these two files. One is a function that inserts data in the base, the other sends an email using php mailer. Function that inserts:
<?php
class MvcBug{
public function nuevoReporteBugController($tabla, $redireccionamiento){
if (isset($_POST["bugReport"])) {
$dato = $_POST["bugReport"];
$dato = trim($dato);
$respuesta = MvcControllerBug::nuevoReporteBugModel($dato, $tabla, $redireccionamiento, $_SESSION["idUsuario"]);
unset($_POST['bugReport']);
}
}
}
And the email output:
<?php
use PHPMailer\PHPMailer\PHPMailer;
require 'mail/autoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.gmail.com';
$mail->Port = 25;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "············";
$mail->Password = "············";
$mail->setFrom('...............', '...........');
$mail->addReplyTo('[email protected]', 'Base');
$mail->addAddress("..........", "...........");
$mail->Subject = "Prueba";
$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
$mail->AltBody = 'This is a plain-text message body';
$mail->send();
?>
Both archives files work separately when executing them, as I could do so that at the moment the function inserts the data and obtains the $ answer, the file of the email is executed so that besides inserting, it notifies me by email that this change was Done?