douzhi3779 2011-11-11 19:06
浏览 17

Zend Mail发送和发送进度条

Does anybody know a good example how to send mail with attachments and display a progressbar in JavaScript (jQuery)?

  • 写回答

1条回答 默认 最新

  • doutang3815 2011-11-11 20:54
    关注

    You're probably going to have to guess the amount of time it takes and update the progress bar based on that.

    Given that PHP doesn't have threading, I would suggest having a database queue for deliveries, and have an external PHP process triggered from the main site (or via cron) that processes the deliveries on the side, marking on the database the current status on each delivery: NOT_PROCESSED, IN_PROGRESS, CONNECTING, CONNECTED, SENDING_DATA, ACCEPTED, FAILURE_X . You can query the database for the status on each delivery via Ajax.

    If PHPMailer internally uses the standard PHP mail() function, which uses a relay SMTP server in your machine, you cannot have that much information about status (which you would have if you created the sockets yourself), you can have just three main states NOT_PROCESSED, IN_PROGRESS, FAILURE_X.

    Is it possible to send mail asycronously using PHP while giving user feedback on delivery?

    Otherwise maybe you could update the progress bar after each little step. Something arbitrary like this:

    1. Set mail recipient
      • update progress bar 25%
    2. Set mail from address
      • update progress bar 50%
    3. Set mail headers
      • update progress bar 75%
    4. Send mail
      • update progress bar to 100%

    This, however, is really inefficient.. And the end result would probably be the user seeing the progress bar jump really fast through the first three (25%, 50%, 75%) and then be stuck on the 75% for a extra second or two and then be done..

    评论

报告相同问题?

悬赏问题

  • ¥15 为什么apriori的运行时间会比fp growth的运行时间短呢
  • ¥15 帮我解决一下膳食平衡的线性规划模型的数据实例
  • ¥40 万年历缺少农历,需要和阳历同时显示
  • ¥250 雷电模拟器内存穿透、寻基址和特征码的教学
  • ¥200 比特币ord程序wallet_constructor.rs文件支持一次性铸造1000个代币,并将它们分配到40个UTXO上(每个UTXO上分配25个代币),并设置找零地址
  • ¥15 关于Java的学习问题
  • ¥15 如何使用chatgpt完成文本分类任务?
  • ¥15 已知速度v关于位置s的等式,怎么转化为已知位置求速度v的等式
  • ¥15 我有个餐饮系统,用wampserver把环境配置好了,但是后端的网页却进去,是为什么,能不能帮远程一下?
  • ¥15 R运行没有名称为"species"的插槽对于此对象类"SDMmodelCV"