Hello.

This patch enhances the imap_mail_compose() function to allow
one to set parameters following the Content-Type header of a message or
of the parts of a multipart message.

This ability is crucial for international users, because they need to
specify the charset of the messages.

The patch adds a new key 'parameter' to the associative array which
imap_mail_compose() uses to create its messages. This key must contain
another array, which keys are the parameters of the header. Any
parametrs can be specified this way, it's not limited to the 'charset'
parameter.

It's used this way:

$part_msg['type'] = TYPETEXT;
$part_msg['subtype'] = 'plain';
$part_msg['parameter']['charset'] = 'iso-8859-2';               

-- 
Tomas Styblo
[EMAIL PROTECTED]
--- php-4.0.6-orig/ext/imap/php_imap.c  Wed May 30 19:27:49 2001
+++ php-4.0.6/ext/imap/php_imap.c       Fri Dec  7 19:47:10 2001
@@ -3174,13 +3174,13 @@
 {
        zval **envelope, **body;
        char *key;
-       zval **data, **pvalue, **disp_data, **env_data;
+       zval **data, **pvalue, **ctype_data, **disp_data, **env_data;
        ulong ind;
        char *cookie = NIL;
        ENVELOPE *env;
        BODY *bod=NULL, *topbod=NULL;
        PART *mypart=NULL, *toppart=NULL, *part;
-       PARAMETER *param, *disp_param = NULL, *custom_headers_param = NULL, *tmp_param 
= NULL;
+       PARAMETER *param, *disp_param = NULL, *ctype_param = NULL, 
+*custom_headers_param = NULL, *tmp_param = NULL;
        char tmp[8 * MAILTMPLEN], *mystring=NULL, *t=NULL, *tempstring=NULL;
        int myargc = ZEND_NUM_ARGS();
 
@@ -3309,6 +3309,23 @@
                                bod->disposition.parameter = disp_param;
                        }
                }
+               if (zend_hash_find(Z_ARRVAL_PP(data), "parameter", 
+sizeof("parameter"), (void **) &pvalue)== SUCCESS) {
+                       if (Z_TYPE_PP(pvalue) == IS_ARRAY) {
+                               ctype_param = tmp_param = NULL;
+                               while (zend_hash_get_current_data(Z_ARRVAL_PP(pvalue), 
+(void **) &ctype_data) == SUCCESS) {
+                                       ctype_param = mail_newbody_parameter();
+                                       zend_hash_get_current_key(Z_ARRVAL_PP(pvalue), 
+&key, &ind, 0);
+                                       ctype_param->attribute = key;
+                                       convert_to_string_ex(ctype_data);
+                                       ctype_param->value = (char *) 
+fs_get(Z_STRLEN_PP(ctype_data) + 1);
+                                       memcpy(ctype_param->value, 
+Z_STRVAL_PP(ctype_data), Z_STRLEN_PP(ctype_data) + 1);
+                                       zend_hash_move_forward(Z_ARRVAL_PP(pvalue));
+                                       ctype_param->next = tmp_param;
+                                       tmp_param = ctype_param;
+                               }
+                               bod->parameter = ctype_param;
+                       }
+               }
                if (zend_hash_find(Z_ARRVAL_PP(data), "contents.data", 
sizeof("contents.data"), (void **) &pvalue)== SUCCESS) {
                        convert_to_string_ex(pvalue);
                        bod->contents.text.data = (char *) fs_get(Z_STRLEN_PP(pvalue) 
+ 1);
@@ -3387,6 +3404,23 @@
                                        bod->disposition.parameter = disp_param;
                                }
                        }
+               if (zend_hash_find(Z_ARRVAL_PP(data), "parameter", 
+sizeof("parameter"), (void **) &pvalue)== SUCCESS) {
+                       if (Z_TYPE_PP(pvalue) == IS_ARRAY) {
+                               ctype_param = tmp_param = NULL;
+                               while (zend_hash_get_current_data(Z_ARRVAL_PP(pvalue), 
+(void **) &ctype_data) == SUCCESS) {
+                                       ctype_param = mail_newbody_parameter();
+                                       zend_hash_get_current_key(Z_ARRVAL_PP(pvalue), 
+&key, &ind, 0);
+                                       ctype_param->attribute = key;
+                                       convert_to_string_ex(ctype_data);
+                                       ctype_param->value = (char *) 
+fs_get(Z_STRLEN_PP(ctype_data) + 1);
+                                       memcpy(ctype_param->value, 
+Z_STRVAL_PP(ctype_data), Z_STRLEN_PP(ctype_data) + 1);
+                                       zend_hash_move_forward(Z_ARRVAL_PP(pvalue));
+                                       ctype_param->next = tmp_param;
+                                       tmp_param = ctype_param;
+                               }
+                               bod->parameter = ctype_param;
+                       }
+               }        
                        if (zend_hash_find(Z_ARRVAL_PP(data), "contents.data", 
sizeof("contents.data"), (void **) &pvalue)== SUCCESS) {
                                convert_to_string_ex(pvalue);
                                bod->contents.text.data = (char *) 
fs_get(Z_STRLEN_PP(pvalue) + 1);

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to