I have a simple jquery script on a main.php
that creates message (see first $.post) and then sends notifications (see second $.post):
$.post('core/functions/user/message/message.create.php', { to_user: to_user, message: message }, function() {
$('.messages').load('account_page_msg.php?page_id=10');
});
$.post('core/functions/user/notify_email.php', { pushTitle: pushTitle, pushMessage: message });
It triggers a notify_email.php
that looks like this:
// email function
$mail = new myPHPMailer;
$mail->isSMTP();
$mail->Host = '..........';
$mail->SMTPAuth = true;
$mail->Username = '.........';
$mail->Password = '.........';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->CharSet = 'UTF-8';
$mail->addAddress('jetprofile@yahoo.com', '');
$mail->setFrom('admin@ihusky.com', 'iHusky.com');
$mail->addReplyTo('jetprofile@yahoo.com', '');
$mail->isHTML(true);
$mail->Subject = 'Test email notifications';
$body = 'Email notifications';
$mail->MsgHTML($body);
$mail->send();
Why is my script on a main.php
waiting for the email function to complete sending email even though I don't have an actual callback? I thought it's supposed to be asynchronous.