I want to send mail in the background, I have a function for it, and it's working fine, but it is blocking my message to pass to the user!
// i tried this
$er=1;
$outmsg = 'You are now registered,please check your email for verification!';
$this->common_model->partialResponse();
$this->mailer->send_mail($mail,$Mailconfig);
$type = ($er==1) ? "success" : "danger";
echo json_encode(array('msgtype'=>$type,'datacon'=>$outmsg));
function partialResponse()
{
$response=array();
ignore_user_abort(true);
ob_start();
echo json_encode($response);
header("Status: 200");
header($_SERVER["SERVER_PROTOCOL"] . " 200 Ok");
header("Content-Type: application/json");
header('Content-Length: '.ob_get_length());
ob_end_flush();
ob_flush();
flush();
}