@@ -3411,7 +3411,8 @@ PHP_FUNCTION(imap_mail_compose)
3411
3411
/* }}} */
3412
3412
3413
3413
/* {{{ _php_imap_mail */
3414
- int _php_imap_mail (char * to , char * subject , char * message , char * headers , char * cc , char * bcc , char * rpath )
3414
+ bool _php_imap_mail (zend_string * to , zend_string * subject , zend_string * message , zend_string * headers ,
3415
+ zend_string * cc , zend_string * bcc , zend_string * rpath )
3415
3416
{
3416
3417
#ifdef PHP_WIN32
3417
3418
int tsm_err ;
@@ -3429,13 +3430,13 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
3429
3430
size_t bt_len ;
3430
3431
3431
3432
if (headers ) {
3432
- bufferLen += strlen (headers );
3433
+ bufferLen += ZSTR_LEN (headers );
3433
3434
}
3434
3435
if (to ) {
3435
- bufferLen += strlen (to ) + 6 ;
3436
+ bufferLen += ZSTR_LEN (to ) + 6 ;
3436
3437
}
3437
3438
if (cc ) {
3438
- bufferLen += strlen (cc ) + 6 ;
3439
+ bufferLen += ZSTR_LEN (cc ) + 6 ;
3439
3440
}
3440
3441
3441
3442
#define PHP_IMAP_CLEAN if (bufferTo) efree(bufferTo); if (bufferCc) efree(bufferCc); if (bufferBcc) efree(bufferBcc); if (bufferHeader) efree(bufferHeader);
@@ -3445,10 +3446,10 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
3445
3446
memset (bufferHeader , 0 , bufferLen );
3446
3447
if (to && * to ) {
3447
3448
strlcat (bufferHeader , "To: " , bufferLen + 1 );
3448
- strlcat (bufferHeader , to , bufferLen + 1 );
3449
+ strlcat (bufferHeader , ZSTR_VAL ( to ) , bufferLen + 1 );
3449
3450
strlcat (bufferHeader , "\r\n" , bufferLen + 1 );
3450
- tempMailTo = estrdup (to );
3451
- bt_len = strlen (to );
3451
+ tempMailTo = estrdup (ZSTR_VAL ( to ) );
3452
+ bt_len = ZSTR_LEN (to );
3452
3453
bufferTo = (char * )safe_emalloc (bt_len , 1 , 1 );
3453
3454
bt_len ++ ;
3454
3455
offset = 0 ;
@@ -3474,10 +3475,10 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
3474
3475
3475
3476
if (cc && * cc ) {
3476
3477
strlcat (bufferHeader , "Cc: " , bufferLen + 1 );
3477
- strlcat (bufferHeader , cc , bufferLen + 1 );
3478
+ strlcat (bufferHeader , ZSTR_VAL ( cc ) , bufferLen + 1 );
3478
3479
strlcat (bufferHeader , "\r\n" , bufferLen + 1 );
3479
- tempMailTo = estrdup (cc );
3480
- bt_len = strlen (cc );
3480
+ tempMailTo = estrdup (ZSTR_VAL ( cc ) );
3481
+ bt_len = ZSTR_LEN (cc );
3481
3482
bufferCc = (char * )safe_emalloc (bt_len , 1 , 1 );
3482
3483
bt_len ++ ;
3483
3484
offset = 0 ;
@@ -3502,8 +3503,8 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
3502
3503
}
3503
3504
3504
3505
if (bcc && * bcc ) {
3505
- tempMailTo = estrdup (bcc );
3506
- bt_len = strlen (bcc );
3506
+ tempMailTo = estrdup (ZSTR_VAL ( bcc ) );
3507
+ bt_len = ZSTR_LEN (bcc );
3507
3508
bufferBcc = (char * )safe_emalloc (bt_len , 1 , 1 );
3508
3509
bt_len ++ ;
3509
3510
offset = 0 ;
@@ -3528,10 +3529,11 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
3528
3529
}
3529
3530
3530
3531
if (headers && * headers ) {
3531
- strlcat (bufferHeader , headers , bufferLen + 1 );
3532
+ strlcat (bufferHeader , ZSTR_VAL ( headers ) , bufferLen + 1 );
3532
3533
}
3533
3534
3534
- if (TSendMail (INI_STR ("SMTP" ), & tsm_err , & tsm_errmsg , bufferHeader , subject , bufferTo , message , bufferCc , bufferBcc , rpath ) != SUCCESS ) {
3535
+ if (TSendMail (INI_STR ("SMTP" ), & tsm_err , & tsm_errmsg , bufferHeader , ZSTR_VAL (subject ),
3536
+ bufferTo , ZSTR_VAL (message ), bufferCc , bufferBcc , ZSTR_VAL (rpath )) != SUCCESS ) {
3535
3537
if (tsm_errmsg ) {
3536
3538
php_error_docref (NULL , E_WARNING , "%s" , tsm_errmsg );
3537
3539
efree (tsm_errmsg );
@@ -3548,15 +3550,15 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
3548
3550
}
3549
3551
sendmail = popen (INI_STR ("sendmail_path" ), "w" );
3550
3552
if (sendmail ) {
3551
- if (rpath && rpath [ 0 ] ) fprintf (sendmail , "From: %s\n" , rpath );
3552
- fprintf (sendmail , "To: %s\n" , to );
3553
- if (cc && cc [ 0 ] ) fprintf (sendmail , "Cc: %s\n" , cc );
3554
- if (bcc && bcc [ 0 ] ) fprintf (sendmail , "Bcc: %s\n" , bcc );
3555
- fprintf (sendmail , "Subject: %s\n" , subject );
3553
+ if (ZSTR_LEN ( rpath ) != 0 ) fprintf (sendmail , "From: %s\n" , ZSTR_VAL ( rpath ) );
3554
+ fprintf (sendmail , "To: %s\n" , ZSTR_VAL ( to ) );
3555
+ if (ZSTR_LEN ( cc ) != 0 ) fprintf (sendmail , "Cc: %s\n" , ZSTR_VAL ( cc ) );
3556
+ if (ZSTR_LEN ( bcc ) != 0 ) fprintf (sendmail , "Bcc: %s\n" , ZSTR_VAL ( bcc ) );
3557
+ fprintf (sendmail , "Subject: %s\n" , ZSTR_VAL ( subject ) );
3556
3558
if (headers != NULL ) {
3557
- fprintf (sendmail , "%s\n" , headers );
3559
+ fprintf (sendmail , "%s\n" , ZSTR_VAL ( headers ) );
3558
3560
}
3559
- fprintf (sendmail , "\n%s\n" , message );
3561
+ fprintf (sendmail , "\n%s\n" , ZSTR_VAL ( message ) );
3560
3562
ret = pclose (sendmail );
3561
3563
3562
3564
return ret != -1 ;
@@ -3598,8 +3600,7 @@ PHP_FUNCTION(imap_mail)
3598
3600
php_error_docref (NULL , E_WARNING , "No message string in mail command" );
3599
3601
}
3600
3602
3601
- if (_php_imap_mail (ZSTR_VAL (to ), ZSTR_VAL (subject ), ZSTR_VAL (message ), headers ?ZSTR_VAL (headers ):NULL , cc ?ZSTR_VAL (cc ):NULL ,
3602
- bcc ?ZSTR_VAL (bcc ):NULL , rpath ?ZSTR_VAL (rpath ):NULL )) {
3603
+ if (_php_imap_mail (to , subject , message , headers , cc , bcc , rpath )) {
3603
3604
RETURN_TRUE ;
3604
3605
} else {
3605
3606
RETURN_FALSE ;
0 commit comments