Send mail without blocking 'execution'

前端 未结 4 676
刺人心
刺人心 2021-01-15 06:36

I\'m using Zend_Mail in a Zend Framework application to send an e-mail with the contents of a web-based contact form.

The mailing itself works fine ( im using a Goog

4条回答
  •  执念已碎
    2021-01-15 07:00

    PHP doesn't allow multi-threading by default. Some ways to get your work done:

    1. Use some message queue service like IronMQ [recommended approach] which makes a secure API/cURL call to your system and spawns off a separate process w/o blocking execution.

    2. Use output buffering in PHP and use ob_flush before finally starting the mail sending operation.

    3. Make the client call the server again via AJAX on success of previous operation.

    4. Install pthreads PECL extension on your server

提交回复
热议问题