Hi
I'm using this framework to my site and i want to receive an email each time a user insert a new record in my database, the problem is, if i use the phpMailer the dialog don't close, i don't the dialog closes but no email is received
This my code
if ($result){
sendEmail();
echo json_encode(array(
'success'=>true,
'message'=>'Atividade Registada com Sucesso'));
} else {
echo json_encode(array('errorMsg'=>'Erro...nada foi registado.'));
}
function sendEmail() {
$email = $_POST['email'];
$atividade = $_REQUEST['nome'];
$data = $_REQUEST['data'];
$hora = $_REQUEST['hora'];
$local = $_REQUEST['local'];
$inter = $_REQUEST['inter'];
$notas = $_REQUEST['notas'];
$newDate = date("Y-m-d", strtotime($data));
$vaiEmail= "A sua atividade foi registada com sucesso\n\nAtividade: $atividade\n\nData: $newDate\n\nHora: $hora\n\nLocal: $local\n\nInterveninentes: $inter\n\nNotas: $notas\n\nObrigado";
$email = $_POST['email'];
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 1;
$mail->Debugoutput = 'html';
$mail->Mailer = "smtp";
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPKeepAlive = true;
$mail->SMTPAuth = true;
$mail->Username = "xxxxxxl@gmail.com";
$mail->Password = "xxxxx";
$mail->setFrom('xxxxx@gmail.com', 'PAAD - Atividades');
$mail->addReplyTo('xxxx@gmail.com', 'PAAD - Atividades');
$mail->addAddress($email);
$mail->Subject = 'Registo de nova atividade';
$mail->Body = $vaiEmail;
}
?>
and my main page, the javascript is:
unction atividadeNova() {
$('#fm').form('submit', {
url: 'nova_atividade.php',
onSubmit: function () {
return $(this).form('validate');
},
success: function (result) {
var result = eval('(' + result + ')');
if (result.errorMsg) {
console.log(result.errorMsg),
$.messager.show({
title: 'EBSPMA Atividades - Erro',
msg: result.errorMsg
});
} else {
$.messager.show({
title: 'EBSPMA Atividades - Sucesso',
msg: result.message,
timeout: 2000,
showType: 'slide',
style: {
right: '',
top: document.body.scrollTop + document.documentElement.scrollTop,
bottom: '',
zIndex: $.fn.window.defaults.zIndex++
}
});
$('#dlg').dialog('close'); // close the dialog
$('#dg').datagrid('reload'); // reload the user data
}
}
});
}
How can i have this working, i mean, insert a new record, close the dailog window and receive a confirmation email?
Thanks