异步调用发送电子邮件(按钮单击后和重定向之前。)

I am trying to do something like below: When a user hits the 'sign up' button, I have to send two emails (one to admin, one to user) and then the redirection. Currently, there is a lag of around 5 seconds before user gets redirected to the welcome page after he hits the sign up button. I am wondering is there any way in Codeigniter or in php that I can make the two calls to send email asynchronous. Both the functions (sendEmailToAdmin() and sendPendingApprovalEmailToUser()) exist in the controller. Sincere thanks in advance for the help.

$this -> users_model -> set_user();
$this -> sendEmailToAdmin();
$email = $this -> input -> post('email');
$this -> sendPendingApprovalEmailToUser($email);
redirect('welcome');

You don't need to do this asynchronous. You may use a Queuing system and push the jobs to the Queue and instantly redirect the user. The Queue Worker will pick up the jobs and send the emails.

Few popular queuing systems:

I think, if use curl to fork 2 processes to handle sending emails to user and admin then redirect user right away would reduce the waiting time, since sending emails could simply stay and runs on the server end, user doesn't need to be involved besides receiving emails.