Index: camel/camel-mime-utils.c
===================================================================
--- camel/camel-mime-utils.c	(revision 9720)
+++ camel/camel-mime-utils.c	(working copy)
@@ -3281,7 +3281,7 @@ camel_header_param_list_decode(const cha
 }
 
 static char *
-header_encode_param (const unsigned char *in, gboolean *encoded)
+header_encode_param (const unsigned char *in, gboolean *encoded, gboolean is_filename)
 {
 	const unsigned char *inptr = in;
 	unsigned char *outbuf = NULL;
@@ -3307,6 +3307,14 @@ header_encode_param (const unsigned char
 			return g_strdup((char *) in);
 	}
 
+	if (is_filename) {
+		/* do not set encoded flag for file names */
+		str = camel_header_encode_string (inptr);
+		g_free (outbuf);
+
+		return str;
+	}
+
 	/* FIXME: set the 'language' as well, assuming we can get that info...? */
 	out = g_string_new (charset);
 	g_string_append(out, "''");
@@ -3322,7 +3330,7 @@ header_encode_param (const unsigned char
 	str = out->str;
 	g_string_free (out, FALSE);
 	*encoded = TRUE;
-	
+
 	return str;
 }
 
@@ -3332,6 +3340,7 @@ camel_header_param_list_format_append (G
 	int used = out->len;
 
 	while (p) {
+		gboolean is_filename = g_ascii_strcasecmp (p->name, "filename") == 0 || g_ascii_strcasecmp (p->name, "name") == 0;
 		gboolean encoded = FALSE;
 		gboolean quote = FALSE;
 		int here = out->len;
@@ -3343,7 +3352,7 @@ camel_header_param_list_format_append (G
 			continue;
 		}
 
-		value = header_encode_param ((unsigned char *) p->value, &encoded);
+		value = header_encode_param ((unsigned char *) p->value, &encoded, is_filename);
 		if (!value) {
 			w(g_warning ("appending parameter %s=%s violates rfc2184", p->name, p->value));
 			value = g_strdup (p->value);
@@ -3363,14 +3372,15 @@ camel_header_param_list_format_append (G
 		nlen = strlen (p->name);
 		vlen = strlen (value);
 
-		if (used + nlen + vlen > CAMEL_FOLD_SIZE - 8) {
+		/* do not fold file names */
+		if (!is_filename && used + nlen + vlen > CAMEL_FOLD_SIZE - 8) {
 			out = g_string_append (out, ";\n\t");
 			here = out->len;
 			used = 0;
 		} else
 			out = g_string_append (out, "; ");
 
-		if (nlen + vlen > CAMEL_FOLD_SIZE - 8) {
+		if (!is_filename && nlen + vlen > CAMEL_FOLD_SIZE - 8) {
 			/* we need to do special rfc2184 parameter wrapping */
 			int maxlen = CAMEL_FOLD_SIZE - (nlen + 8);
 			char *inptr, *inend;
Index: camel/ChangeLog
===================================================================
--- camel/ChangeLog	(revision 9720)
+++ camel/ChangeLog	(working copy)
@@ -1,3 +1,13 @@
+2008-11-03  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #524377
+
+	* camel-mime-utils.c: (header_encode_param),
+	(camel_header_param_list_format_append): Encode 'filename' and 'name'
+	parameters based on RFC 2047, instead of the correct RFC 2231, because
+	other clients/servers (like Outlook and Gmail) do not understand
+	the standard encoding.
+
 2008-10-31  Matthew Barnes  <mbarnes@redhat.com>
 
 	** Fixes part of bug #558727 (patch by Frederic van Starbmann)
