Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using sSMTP with PHP for e-mail sending and it works fine.

The problem is that sSMTP performs the delivery synchronously which adds latency to my PHP scripts, letting the user waiting a little too long.

Is there a way to make it work non-blocking?

(I though of a hack on the shell, to start the sSMTP process on the background or something, and return earlier back to PHP, but I could not make it work.)

share|improve this question

3 Answers 3

You can use gearman or other similar techniques do make blocking things asynchronously. See http://www.phpclasses.org/blog/post/108-Distributing-PHP-processing-with-Gearman.html

share|improve this answer

Yes use one of the nullmailers which supports queueing or a full MTA instead of ssmtp. While you could write a wrapper around SSMTP, it'll need to fork and setsid to isolate from the calling php process.

share|improve this answer
up vote 0 down vote accepted

Ok, I figured it out! Using the script command we can write a wrapper:

#!/bin/sh
script -q -c "/usr/sbin/ssmtp $*" /dev/null
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.