@@ -265,7 +265,7 @@ PHP_FUNCTION(mail)
265
265
headers_str = php_trim (headers_str , NULL , 0 , 2 );
266
266
} else if (headers_ht ) {
267
267
headers_str = php_mail_build_headers (headers_ht );
268
- if (EG ( exception ) ) {
268
+ if (headers_str == NULL ) {
269
269
RETURN_THROWS ();
270
270
}
271
271
}
@@ -408,14 +408,9 @@ static int php_mail_detect_multiple_crlf(const char *hdr) {
408
408
409
409
410
410
/* {{{ php_mail */
411
- PHPAPI int php_mail (const char * to , const char * subject , const char * message , const char * headers , const char * extra_cmd )
411
+ PHPAPI bool php_mail (const char * to , const char * subject , const char * message , const char * headers , const char * extra_cmd )
412
412
{
413
- #ifdef PHP_WIN32
414
- int tsm_err ;
415
- char * tsm_errmsg = NULL ;
416
- #endif
417
413
FILE * sendmail ;
418
- int ret ;
419
414
char * sendmail_path = INI_STR ("sendmail_path" );
420
415
char * sendmail_cmd = NULL ;
421
416
char * mail_log = INI_STR ("mail.log" );
@@ -464,7 +459,7 @@ PHPAPI int php_mail(const char *to, const char *subject, const char *message, co
464
459
}
465
460
466
461
if (EG (exception )) {
467
- MAIL_RET (0 );
462
+ MAIL_RET (false );
468
463
}
469
464
470
465
char * line_sep = PG (mail_mixed_lf_and_crlf ) ? "\n" : "\r\n" ;
@@ -486,11 +481,14 @@ PHPAPI int php_mail(const char *to, const char *subject, const char *message, co
486
481
487
482
if (hdr && php_mail_detect_multiple_crlf (hdr )) {
488
483
php_error_docref (NULL , E_WARNING , "Multiple or malformed newlines found in additional_header" );
489
- MAIL_RET (0 );
484
+ MAIL_RET (false );
490
485
}
491
486
492
487
if (!sendmail_path ) {
493
488
#ifdef PHP_WIN32
489
+ int tsm_err ;
490
+ char * tsm_errmsg = NULL ;
491
+
494
492
/* handle old style win smtp sending */
495
493
if (TSendMail (INI_STR ("SMTP" ), & tsm_err , & tsm_errmsg , hdr , subject , to , message , NULL , NULL , NULL ) == FAILURE ) {
496
494
if (tsm_errmsg ) {
@@ -499,11 +497,11 @@ PHPAPI int php_mail(const char *to, const char *subject, const char *message, co
499
497
} else {
500
498
php_error_docref (NULL , E_WARNING , "%s" , GetSMErrorText (tsm_err ));
501
499
}
502
- MAIL_RET (0 );
500
+ MAIL_RET (false );
503
501
}
504
- MAIL_RET (1 );
502
+ MAIL_RET (true );
505
503
#else
506
- MAIL_RET (0 );
504
+ MAIL_RET (false );
507
505
#endif
508
506
}
509
507
if (extra_cmd != NULL ) {
@@ -547,7 +545,7 @@ PHPAPI int php_mail(const char *to, const char *subject, const char *message, co
547
545
signal (SIGCHLD , sig_handler );
548
546
}
549
547
#endif
550
- MAIL_RET (0 );
548
+ MAIL_RET (false );
551
549
}
552
550
#endif
553
551
fprintf (sendmail , "To: %s%s" , to , line_sep );
@@ -556,7 +554,7 @@ PHPAPI int php_mail(const char *to, const char *subject, const char *message, co
556
554
fprintf (sendmail , "%s%s" , hdr , line_sep );
557
555
}
558
556
fprintf (sendmail , "%s%s%s" , line_sep , message , line_sep );
559
- ret = pclose (sendmail );
557
+ int ret = pclose (sendmail );
560
558
561
559
#if PHP_SIGCHILD
562
560
if (sig_handler ) {
@@ -576,9 +574,9 @@ PHPAPI int php_mail(const char *to, const char *subject, const char *message, co
576
574
#endif
577
575
#endif
578
576
{
579
- MAIL_RET (0 );
577
+ MAIL_RET (false );
580
578
} else {
581
- MAIL_RET (1 );
579
+ MAIL_RET (true );
582
580
}
583
581
} else {
584
582
php_error_docref (NULL , E_WARNING , "Could not execute mail delivery program '%s'" , sendmail_path );
@@ -587,10 +585,10 @@ PHPAPI int php_mail(const char *to, const char *subject, const char *message, co
587
585
signal (SIGCHLD , sig_handler );
588
586
}
589
587
#endif
590
- MAIL_RET (0 );
588
+ MAIL_RET (false );
591
589
}
592
590
593
- MAIL_RET (1 ); /* never reached */
591
+ MAIL_RET (true ); /* never reached */
594
592
}
595
593
/* }}} */
596
594
0 commit comments