Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save celadevra/5660812 to your computer and use it in GitHub Desktop.
Save celadevra/5660812 to your computer and use it in GitHub Desktop.
Enable mutt 1.5.21 to send attachments conforming to RFC 2047
diff -uNr mutt-1.5.21.orig/PATCHES mutt-1.5.21/PATCHES
--- mutt-1.5.21.orig/PATCHES 2008-03-20 04:07:06.000000000 +0800
+++ mutt-1.5.21/PATCHES 2013-05-28 14:12:57.000000000 +0800
@@ -0,0 +1 @@
+patch-1.5.21.tt.create_rfc2047_params.1
diff -uNr mutt-1.5.21.orig/init.h mutt-1.5.21/init.h
--- mutt-1.5.21.orig/init.h 2010-09-15 23:39:31.000000000 +0800
+++ mutt-1.5.21/init.h 2013-05-28 10:50:19.000000000 +0800
@@ -419,6 +419,18 @@
** characters as question marks which can lead to undesired
** side effects (for example in regular expressions).
*/
+ { "create_rfc2047_parameters", DT_BOOL, R_NONE, OPTCREATERFC2047PARAMS, 0 },
+ /*
+ ** .pp
+ ** When this variable is set, Mutt will add the following RFC-2047-encoded
+ ** MIME parameter to Content-Type header field as filename for attachment:
+ ** name="=?iso-2022-jp?B?GyRCO244MxsoQi50eHQ=?="
+ ** .pp
+ ** Note: this use of RFC 2047's encoding is explicitly prohibited
+ ** by the standard. You may set this variable only if a mailer
+ ** of recipients can not parse RFC 2231 parameters.
+ */
+
{ "confirmappend", DT_BOOL, R_NONE, OPTCONFIRMAPPEND, 1 },
/*
** .pp
diff -uNr mutt-1.5.21.orig/mutt.h mutt-1.5.21/mutt.h
--- mutt-1.5.21.orig/mutt.h 2010-09-14 01:19:55.000000000 +0800
+++ mutt-1.5.21/mutt.h 2013-05-28 10:52:06.000000000 +0800
@@ -331,6 +330,7 @@
OPTCOLLAPSEUNREAD,
OPTCONFIRMAPPEND,
OPTCONFIRMCREATE,
+ OPTCREATERFC2047PARAMS,
OPTDELETEUNTAG,
OPTDIGESTCOLLAPSE,
OPTDUPTHREADS,
diff -uNr mutt-1.5.21.orig/sendlib.c mutt-1.5.21/sendlib.c
--- mutt-1.5.21.orig/sendlib.c 2010-09-14 01:19:55.000000000 +0800
+++ mutt-1.5.21/sendlib.c 2013-05-28 11:16:26.000000000 +0800
@@ -347,6 +347,33 @@
}
}
+ if (a->use_disp && option (OPTCREATERFC2047PARAMS))
+ {
+ if(!(fn = a->d_filename))
+ fn = a->filename;
+
+ if (fn)
+ {
+ char *tmp;
+
+ /* Strip off the leading path... */
+ if ((t = strrchr (fn, '/')))
+ t++;
+ else
+ t = fn;
+
+ /* length of content-type */
+ len = 21 + mutt_strlen (TYPE (a)) + mutt_strlen (a->subtype);
+
+ buffer[0] = 0;
+ tmp = safe_strdup (t);
+ _rfc2047_encode_string (&tmp, 0, len);
+ rfc822_cat (buffer, sizeof (buffer), tmp, MimeSpecials);
+ FREE (&tmp);
+ fprintf (f, "; name=%s", buffer);
+ }
+ }
+
fputc ('\n', f);
@celadevra
Copy link
Author

Usage: patch, compile, edit .muttrc:

Add the line

set create_rfc2047_parameters=yes

restart mutt. All email attachments sent are now conforming to rfc 2047 and therefore can be read by Foxmail and older versions of Outlook (Express). You can also set send-hook to limit the behaviour to sending to certain addresses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment