Fix soap api for nginx/php-fpm performance optimisation

 and sending emails. Also fix if logging to page, send emails early such that
 logs include all email log entries.