@@ -4318,7 +4318,9 @@ PHP_FUNCTION(mb_send_mail)
43184318 if (orig_str .encoding -> no_encoding == mbfl_no_encoding_invalid || orig_str .encoding -> no_encoding == mbfl_no_encoding_pass ) {
43194319 orig_str .encoding = mb_guess_encoding ((unsigned char * )subject , subject_len , MBSTRG (current_detect_order_list ), MBSTRG (current_detect_order_list_size ), MBSTRG (strict_detection ));
43204320 }
4321- pstr = mbfl_mime_header_encode (& orig_str , & conv_str , tran_cs , head_enc , CRLF , sizeof ("Subject: [PHP-jp nnnnnnnn]" CRLF ) - 1 );
4321+ const char * line_sep = PG (mail_mixed_lf_and_crlf ) ? "\n" : CRLF ;
4322+ size_t line_sep_len = strlen (line_sep );
4323+ pstr = mbfl_mime_header_encode (& orig_str , & conv_str , tran_cs , head_enc , line_sep , strlen ("Subject: [PHP-jp nnnnnnnn]" ) + line_sep_len );
43224324 if (pstr != NULL ) {
43234325 subject_buf = subject = (char * )pstr -> val ;
43244326 }
@@ -4356,14 +4358,14 @@ PHP_FUNCTION(mb_send_mail)
43564358 n = ZSTR_LEN (str_headers );
43574359 mbfl_memory_device_strncat (& device , p , n );
43584360 if (n > 0 && p [n - 1 ] != '\n' ) {
4359- mbfl_memory_device_strncat (& device , CRLF , sizeof ( CRLF ) - 1 );
4361+ mbfl_memory_device_strncat (& device , line_sep , line_sep_len );
43604362 }
43614363 zend_string_release_ex (str_headers , 0 );
43624364 }
43634365
43644366 if (!zend_hash_str_exists (& ht_headers , "mime-version" , sizeof ("mime-version" ) - 1 )) {
43654367 mbfl_memory_device_strncat (& device , PHP_MBSTR_MAIL_MIME_HEADER1 , sizeof (PHP_MBSTR_MAIL_MIME_HEADER1 ) - 1 );
4366- mbfl_memory_device_strncat (& device , CRLF , sizeof ( CRLF ) - 1 );
4368+ mbfl_memory_device_strncat (& device , line_sep , line_sep_len );
43674369 }
43684370
43694371 if (!suppressed_hdrs .cnt_type ) {
@@ -4374,7 +4376,7 @@ PHP_FUNCTION(mb_send_mail)
43744376 mbfl_memory_device_strncat (& device , PHP_MBSTR_MAIL_MIME_HEADER3 , sizeof (PHP_MBSTR_MAIL_MIME_HEADER3 ) - 1 );
43754377 mbfl_memory_device_strcat (& device , p );
43764378 }
4377- mbfl_memory_device_strncat (& device , CRLF , sizeof ( CRLF ) - 1 );
4379+ mbfl_memory_device_strncat (& device , line_sep , line_sep_len );
43784380 }
43794381 if (!suppressed_hdrs .cnt_trans_enc ) {
43804382 mbfl_memory_device_strncat (& device , PHP_MBSTR_MAIL_MIME_HEADER4 , sizeof (PHP_MBSTR_MAIL_MIME_HEADER4 ) - 1 );
@@ -4383,10 +4385,12 @@ PHP_FUNCTION(mb_send_mail)
43834385 p = "7bit" ;
43844386 }
43854387 mbfl_memory_device_strcat (& device , p );
4386- mbfl_memory_device_strncat (& device , CRLF , sizeof ( CRLF ) - 1 );
4388+ mbfl_memory_device_strncat (& device , line_sep , line_sep_len );
43874389 }
43884390
4389- mbfl_memory_device_unput (& device );
4391+ if (!PG (mail_mixed_lf_and_crlf )) {
4392+ mbfl_memory_device_unput (& device );
4393+ }
43904394 mbfl_memory_device_unput (& device );
43914395 mbfl_memory_device_output ('\0' , & device );
43924396 str_headers = zend_string_init ((char * )device .buffer , strlen ((char * )device .buffer ), 0 );
0 commit comments