mu4e - forward as an attachment

913 views
Skip to first unread message

James Ladan

unread,
Mar 21, 2012, 6:51:32 PM3/21/12
to mu-di...@googlegroups.com
Is there any easy way to forward an email as an attachment? Get the filename and then compose a new email and attach the file?

The anti-spam setup at my workplace requires submitting spam reports by forwarding the email received as an attachment.

Thanks,
James.

Dirk-Jan C. Binnema

unread,
Mar 22, 2012, 3:16:03 PM3/22/12
to mu-di...@googlegroups.com
Hi James,

That sounds like a good idea; it may also be useful for forwarding
rich-text-heavy mail as-is. Let me see if I can do something for this.

(I plan to do a few more features, and then maybe do 0.9.8.3 at the
start of April. There are enough fixes and improvements, I think).

Best wishes,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C

James

unread,
Mar 22, 2012, 4:02:18 PM3/22/12
to mu-di...@googlegroups.com
On Thu, Mar 22, 2012 at 12:16 PM, Dirk-Jan C. Binnema
<dj...@djcbsoftware.nl> wrote:
> On Thu 22 Mar 2012 12:51:32 AM EET, James Ladan wrote:
>
>> Is there any easy way to forward an email as an attachment? Get the
>> filename and then compose a new email and attach the file?
>
> That sounds like a good idea; it may also be useful for forwarding
> rich-text-heavy mail as-is. Let me see if I can do something for this.

Nice, thanks. Maybe using C-u F for it would make sense? If I think
I'll have time to take a look, I'll email first to make sure you
haven't already started.

Thanks,
James.

Dirk-Jan C. Binnema

unread,
Apr 15, 2012, 3:52:22 PM4/15/12
to mu-di...@googlegroups.com, ja...@ladan.ca
Hi James,

I have added something for this now (in git). It's experimental but
should do more or less what you want:

- go to the message you want to include as an attachment
- M-x mu4e-capture-message
- now, while composing a message: M-x mu4e-insert-captured-message

now, the message is included as an RFC-822 attachment. which should be
understandable by other mailers.

James Ladan

unread,
Apr 17, 2012, 9:53:24 PM4/17/12
to mu-di...@googlegroups.com
Hi Dirk,

On Sun, Apr 15, 2012 at 12:52, Dirk-Jan C. Binnema <dj...@djcbsoftware.nl> wrote:
> On Thu 22 Mar 2012 10:02:18 PM EET, James wrote:
>  > On Thu, Mar 22, 2012 at 12:16 PM, Dirk-Jan C. Binnema
>  > <dj...@djcbsoftware.nl> wrote:
>  > > On Thu 22 Mar 2012 12:51:32 AM EET, James Ladan wrote:
>  > >
>  > >> Is there any easy way to forward an email as an attachment? Get the
>  > >> filename and then compose a new email and attach the file?

...


>
> I have added something for this now (in git). It's experimental but
> should do more or less what you want:
>
>  - go to the message you want to include as an attachment
>  - M-x mu4e-capture-message
>  - now, while composing a message: M-x mu4e-insert-captured-message
>
> now, the message is included as an RFC-822 attachment. which should be
> understandable by other mailers.

Sounds like a good start. Unfortunately, I just updated and can't seem
to build mu. The last commit is:

commit 94fcaf16a6d8a61d6edf35a03f5bb574d307765b
Author: djcb <dj...@djcbsoftware.nl>
Date: Tue Apr 17 20:37:18 2012 +0300

* update gitignore

After a git clean, the output is:

autoreconf -i && ./configure && make -j8 && sudo make install
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./config.guess'
libtoolize: copying file `./config.sub'
libtoolize: copying file `./install-sh'
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
configure.ac:23: installing `./missing'
contrib/Makefile.am: installing `./depcomp'
configure.ac:280: required file `emacs/version.texi.in' not found
emacs/Makefile.am:21: installing `emacs/mdate-sh'
emacs/Makefile.am:21: installing `emacs/texinfo.tex'
emacs/Makefile.am:26: installing `./elisp-comp'
guile/Makefile.am:51: installing `guile/texinfo.tex'
Makefile.am: installing `./INSTALL'
autoreconf: automake failed with exit status: 1

Thanks,
James.

Dirk-Jan C. Binnema

unread,
Apr 18, 2012, 12:21:58 AM4/18/12
to mu-di...@googlegroups.com
Hi James,

James Ladan <ja...@ladan.ca> writes:

> On Sun, Apr 15, 2012 at 12:52, Dirk-Jan C. Binnema <dj...@djcbsoftware.nl> wrote:
>> On Thu 22 Mar 2012 10:02:18 PM EET, James wrote:
>> > On Thu, Mar 22, 2012 at 12:16 PM, Dirk-Jan C. Binnema
>> > <dj...@djcbsoftware.nl> wrote:
>> > > On Thu 22 Mar 2012 12:51:32 AM EET, James Ladan wrote:
>> > >
>> > >> Is there any easy way to forward an email as an attachment? Get the
>> > >> filename and then compose a new email and attach the file?
> ...
>>
>> I have added something for this now (in git). It's experimental but
>> should do more or less what you want:
>>
>> - go to the message you want to include as an attachment
>> - M-x mu4e-capture-message
>> - now, while composing a message: M-x mu4e-insert-captured-message
>>
>> now, the message is included as an RFC-822 attachment. which should be
>> understandable by other mailers.
>
> Sounds like a good start. Unfortunately, I just updated and can't seem
> to build mu. The last commit is:
>
> commit 94fcaf16a6d8a61d6edf35a03f5bb574d307765b
> Author: djcb <dj...@djcbsoftware.nl>
> Date: Tue Apr 17 20:37:18 2012 +0300
>
> * update gitignore

Ah, I forgot to add one little file; I have done so now. Lather, rinse,
repeat :)


Thanks,

James Ladan

unread,
Apr 18, 2012, 1:38:37 PM4/18/12
to mu-di...@googlegroups.com
Hi Dirk,

On Tuesday, 17 April 2012 21:21:58 UTC-7, djcb wrote:

>> I have added something for this now (in git). It's experimental but
>> should do more or less what you want:
>>
>>  - go to the message you want to include as an attachment
>>  - M-x mu4e-capture-message
>>  - now, while composing a message: M-x mu4e-insert-captured-message
>>
>> now, the message is included as an RFC-822 attachment. which should be
>> understandable by other mailers.

Ah, I forgot to add one little file; I have done so now. Lather, rinse,
repeat :)

:)

Seems to be working well, though I ran into one piece of junk mail that whether I used the capture-message function or copied the filename and attached it with C-c a (selecting message/rft822 as the content type), I get this error:

message-send-mail: Assertion failed: (save-excursion (goto-char (point-min)) (not (re-search-forward "[^^@-ÿ]" nil t)))

I couldn't find any related output in *mu4e-log* -- the last thing aside from mail updating is the "view" entry where I viewed the spam message. I'll email that message to you directly in case it helps.

As a test, I forwarded a different email as an attachment to myself right afterwards and it was fine. It seems to be something about this one email message.

Thanks,
James.

Dirk-Jan C. Binnema

unread,
Apr 18, 2012, 4:49:45 PM4/18/12
to mu-di...@googlegroups.com
Hi James,

James Ladan <ja...@ladan.ca> writes:

> On Tuesday, 17 April 2012 21:21:58 UTC-7, djcb wrote:
>>
>> >> I have added something for this now (in git). It's experimental but
>> >> should do more or less what you want:
>> >>
>> >> - go to the message you want to include as an attachment
>> >> - M-x mu4e-capture-message
>> >> - now, while composing a message: M-x mu4e-insert-captured-message
>> >>
>> >> now, the message is included as an RFC-822 attachment. which should be
>> >> understandable by other mailers.
>>
>> Ah, I forgot to add one little file; I have done so now. Lather, rinse,
>> repeat :)

> Seems to be working well, though I ran into one piece of junk mail that
> whether I used the capture-message function or copied the filename and
> attached it with C-c a (selecting message/rft822 as the content type), I
> get this error:
>
> message-send-mail: Assertion failed: (save-excursion (goto-char
> (point-min)) (not (re-search-forward "[^^@-ÿ]" nil t)))
>
> I couldn't find any related output in *mu4e-log* -- the last thing aside
> from mail updating is the "view" entry where I viewed the spam message.
> I'll email that message to you directly in case it helps.

Hmm... I couldn't reproduce the problem (recent emacs 24)... it /seems/
like a problem in in message-mode. Can you try C-x m and then try to
send it? That should invoke message-mode without any mu4e.

Otherwise, it'd be interesting to see the backtrace (M-x
toggle-debug-on-error before trying to send the message).

Best wishes,

James Ladan

unread,
Apr 27, 2012, 5:16:31 PM4/27/12
to mu-di...@googlegroups.com
Hi Dirk,

On Wed, Apr 18, 2012 at 13:49, Dirk-Jan C. Binnema <dj...@djcbsoftware.nl> wrote:
> James Ladan <ja...@ladan.ca> writes:
> > Seems to be working well, though I ran into one piece of junk mail that
> > whether I used the capture-message function or copied the filename and
> > attached it with C-c a (selecting message/rft822 as the content type), I
> > get this error:
> >
> > message-send-mail: Assertion failed: (save-excursion (goto-char
> > (point-min)) (not (re-search-forward "[^^@-ÿ]" nil t)))
> >
> > I couldn't find any related output in *mu4e-log* -- the last thing aside
> > from mail updating is the "view" entry where I viewed the spam message.
> > I'll email that message to you directly in case it helps.
>
> Hmm... I couldn't reproduce the problem (recent emacs 24)... it /seems/
> like a problem in in message-mode. Can you try C-x m and then try to
> send it? That should invoke message-mode without any mu4e.

Finally got around to trying this. Same exact problem. Works fine when
I set it to application/octet-stream, but then I don't know if that
uses the correct format for a recipient.

Thanks,
James.

Dirk-Jan C. Binnema

unread,
Apr 28, 2012, 5:24:49 AM4/28/12
to mu-di...@googlegroups.com
Hi James,

James Ladan <ja...@ladan.ca> writes:

> On Wed, Apr 18, 2012 at 13:49, Dirk-Jan C. Binnema <dj...@djcbsoftware.nl> wrote:
>> James Ladan <ja...@ladan.ca> writes:
>> > Seems to be working well, though I ran into one piece of junk mail that
>> > whether I used the capture-message function or copied the filename and
>> > attached it with C-c a (selecting message/rft822 as the content type), I
>> > get this error:
>> >
>> > message-send-mail: Assertion failed: (save-excursion (goto-char
>> > (point-min)) (not (re-search-forward "[^^@-ÿ]" nil t)))
>> >
>> > I couldn't find any related output in *mu4e-log* -- the last thing aside
>> > from mail updating is the "view" entry where I viewed the spam message.
>> > I'll email that message to you directly in case it helps.
>>
>> Hmm... I couldn't reproduce the problem (recent emacs 24)... it /seems/
>> like a problem in in message-mode. Can you try C-x m and then try to
>> send it? That should invoke message-mode without any mu4e.

I can reproduce it now at least; it's some check in message-mode. The
example message you sent contains a single non-ascii character, which
message mode does not like. It's the dash in "2012—Booth" in the message
body. That's indeed not valid RFC822.

It's no a mu4e-specific problem (you get the exact same thing in
e.g. gnus), but that does not really help you, of course :/

> Finally got around to trying this. Same exact problem. Works fine when
> I set it to application/octet-stream, but then I don't know if that
> uses the correct format for a recipient.

I'll try to convince message-mode to use some other encoding
(quoted-printable or base64) for message/rfc822 attachments.

If that doesn't work, I'll probably set the mime-type to
application/octet-stream, maybe after checking the message. That's not
so nice, but at least it works... it should work for the recipients as
well, although of course the recipient's mailer may be able to show the
message in a nicer way if we'd send as message/rfc822.

Rob Stewart

unread,
Oct 14, 2014, 4:34:50 AM10/14/14
to mu-di...@googlegroups.com, ja...@ladan.ca
On Sunday, 15 April 2012 20:52:22 UTC+1, djcb wrote:

I have added something for this now (in git). It's experimental but
should do more or less what you want:

 - go to the message you want to include as an attachment
 - M-x mu4e-capture-message
 - now, while composing a message: M-x mu4e-insert-captured-message

now, the message is included as an RFC-822 attachment. which should be
understandable by other mailers.

The mu4e-capture-message command appears to no longer exist. Is there now an alternative method of forwarding emails as attached messages?

Thanks,

--
Rob

 

--
Dirk-Jan C. Binnema                  Helsinki, Finland

Dirk-Jan C. Binnema

unread,
Oct 14, 2014, 4:45:37 AM10/14/14
to mu-di...@googlegroups.com, ja...@ladan.ca

On Tuesday Oct 14 2014, Rob Stewart wrote:

> On Sunday, 15 April 2012 20:52:22 UTC+1, djcb wrote:
>
> I have added something for this now (in git). It's experimental but
>> should do more or less what you want:
>>
>> - go to the message you want to include as an attachment
>> - M-x mu4e-capture-message
>> - now, while composing a message: M-x mu4e-insert-captured-message
>>
>> now, the message is included as an RFC-822 attachment. which should be
>> understandable by other mailers.
>>
> The mu4e-capture-message command appears to no longer exist. Is there now
> an alternative method of forwarding emails as attached messages?

http://www.djcbsoftware.nl/code/mu/mu4e/HV-Actions.html

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl

Rob Stewart

unread,
Oct 14, 2014, 4:55:00 AM10/14/14
to mu-di...@googlegroups.com
On 14 October 2014 09:45, Dirk-Jan C. Binnema <dj...@djcbsoftware.nl> wrote:

>> The mu4e-capture-message command appears to no longer exist. Is there now
>> an alternative method of forwarding emails as attached messages?
>
> http://www.djcbsoftware.nl/code/mu/mu4e/HV-Actions.html

Works great, thanks!

--
Rob

James Ladan

unread,
Nov 2, 2016, 5:20:11 PM11/2/16
to mu-discuss
Hi all,

Way, way back, I asked about message-mode complaining about invalid characters in rfc822 attachments. Has anyone else encountered this and found a solution?

I tried adding an "encoding=base64" to the attachment metadata but that didn't help.


On Saturday, 28 April 2012 02:24:49 UTC-7, djcb wrote:
James Ladan <ja...@ladan.ca> writes:
> On Wed, Apr 18, 2012 at 13:49, Dirk-Jan C. Binnema <dj...@djcbsoftware.nl> wrote:
>> James Ladan <ja...@ladan.ca> writes:
>> > Seems to be working well, though I ran into one piece of junk mail that
>> > whether I used the capture-message function or copied the filename and
>> > attached it with C-c a (selecting message/rft822 as the content type), I
>> > get this error:
>> >
>> > message-send-mail: Assertion failed: (save-excursion (goto-char
>> > (point-min)) (not (re-search-forward "[^^@-ÿ]" nil t)))
...

I can reproduce it now at least; it's some check in message-mode. The
example message you sent contains a single non-ascii character, which
message mode does not like. It's the dash in "2012—Booth" in the message
body. That's indeed not valid RFC822.

It's no a mu4e-specific problem (you get the exact same thing in
e.g. gnus), but that does not really help you, of course :/
...

I'll try to convince message-mode to use some other encoding
(quoted-printable or base64) for message/rfc822 attachments.

Thanks,
James. 

David Sterratt

unread,
Jan 31, 2017, 10:52:19 AM1/31/17
to mu-discuss
Hello James et al.,

see the bug report with workaround at: https://github.com/djcb/mu/issues/1019

David.
Reply all
Reply to author
Forward
0 new messages