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.)
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.
This works with sendmail piping. Here is an example of what the data that gets piped looks like
Save this script as
/usr/sbin/sendmail
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
Ok, I figured it out! Using the
script
command we can write a wrapper: