@@ -489,34 +489,35 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
489
489
return val; \
490
490
491
491
if (mail_log && * mail_log ) {
492
- char * tmp ;
493
- time_t curtime ;
494
- size_t l ;
495
- zend_string * date_str ;
492
+ char * logline ;
496
493
497
- time (& curtime );
498
- date_str = php_format_date ("d-M-Y H:i:s e" , 13 , curtime , 1 );
499
-
500
- l = spprintf (& tmp , 0 , "[%s] mail() on [%s:%d]: To: %s -- Headers: %s -- Subject: %s\n" , ZSTR_VAL (date_str ), zend_get_executed_filename (), zend_get_executed_lineno (), to , hdr ? hdr : "" , subject );
501
-
502
- zend_string_free (date_str );
494
+ spprintf (& logline , 0 , "mail() on [%s:%d]: To: %s -- Headers: %s -- Subject: %s" , zend_get_executed_filename (), zend_get_executed_lineno (), to , hdr ? hdr : "" , subject );
503
495
504
496
if (hdr ) {
505
- php_mail_log_crlf_to_spaces (tmp );
497
+ php_mail_log_crlf_to_spaces (logline );
506
498
}
507
499
508
500
if (!strcmp (mail_log , "syslog" )) {
509
- /* Drop the final space when logging to syslog. */
510
- tmp [l - 1 ] = 0 ;
511
- php_mail_log_to_syslog (tmp );
512
- }
513
- else {
514
- /* Convert the final space to a newline when logging to file. */
515
- tmp [l - 1 ] = '\n' ;
516
- php_mail_log_to_file (mail_log , tmp , l );
501
+ php_mail_log_to_syslog (logline );
502
+ } else {
503
+ /* Add date when logging to file */
504
+ char * tmp ;
505
+ time_t curtime ;
506
+ zend_string * date_str ;
507
+ size_t len ;
508
+
509
+
510
+ time (& curtime );
511
+ date_str = php_format_date ("d-M-Y H:i:s e" , 13 , curtime , 1 );
512
+ len = spprintf (& tmp , 0 , "[%s] %s%s" , date_str -> val , logline , PHP_EOL );
513
+
514
+ php_mail_log_to_file (mail_log , tmp , len );
515
+
516
+ zend_string_free (date_str );
517
+ efree (tmp );
517
518
}
518
519
519
- efree (tmp );
520
+ efree (logline );
520
521
}
521
522
522
523
if (PG (mail_x_header )) {
0 commit comments