EasyUI Forum
November 05, 2025, 04:18:41 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: phpMailer with dialog error  (Read 6359 times)
alphasil
Guest
« on: March 05, 2015, 03:03:07 PM »

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
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:

Code:

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
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!