+ if (mail_log) { + char *tmp; + int l = spprintf(&tmp, 0, "mail() on [%s:%d]: To: %s -- Headers: %s\n", zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : ""); + if (headers != NULL) { + spprintf(&tmp, 0, "%s\r\nX-PHP-Originating-Script: %ld:%s\r\n", headers, php_getuid(), f); + } else { + spprintf(&tmp, 0, "X-PHP-Originating-Script: %ld:%s\r\n", php_getuid(), f); + } + if (hdr) { /* find all \r\n instances and replace them with spaces, so a log line is always one line long */ + char *p = tmp; + while ((p = strpbrk(p, "\r\n"))) { + *p = ' '; + } + tmp[l - 1] = '\n'; + } + _php_error_log(3, tmp, mail_log, NULL TSRMLS_CC); + efree(tmp); + }