doubipiao1611 2016-09-24 21:56
浏览 92

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

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');
  • 写回答

2条回答 默认 最新

  • drgd73844 2016-09-24 22:00
    关注

    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:

    评论

报告相同问题?

悬赏问题

  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
  • ¥15 php 同步电商平台多个店铺增量订单和订单状态