Discussion:
[Mimedefang] base64 to text
Michael Fox
2017-09-25 17:46:01 UTC
Permalink
I have what is probably an unusual problem to solve. I'm willing to do the
work to solve it. But as someone new to MIMEDefang in particular and MIME
details in general, I want to first get a sanity check to see if what I'd
like to do is reasonably possible, and then see if perhaps parts of the
problem have already been solved by others.



Problem:

I have hundreds of old (but necessary) email clients that only understand
plain text. They can accept a single-part MIME text/plain message, I think
because they just ignore the header. (For the curious, these are amateur
radio BBS systems that speak SMTP, but were developed before MIME existed.
They still have relevance/usefulness for communications in the field,
especially emergency communications over great distances).



I'd like to be able to deliver HTML and Base64 messages to those clients.



Already Solved:



I'm using the built-in remove_redundant_html_parts() function and it works
great, where that situation applies.





Yet to Be Solved/Can this be Solved?:



I'd like be able to deal with text-to-email. For example, Sprint takes a
basic ascii-text message, wraps it in html, and then base64-encodes it prior
to sending. The recipient receives a single-part mime message with
Content-Type of text/html; charset="UTF-8", and Content-Transfer-Encoding of
base64.



I think what would need to be done is to decode the base64, which would
result in plain html (not a multi-part html with redundant plain text), and
then strip the extra html. I'd love to be able to do both steps. But even
decoding base64 to the underlying html would make the message readable by a
human. And, being new to MIMEDefang, I don't know if this type of pipeline
processing of a single mime part is viable. It's certainly different than
just throwing away redundant parts.



So, is this something that's in the realm of reasonable for MIMEDefang to
handle? If so, would I need to start from scratch? Or, do at least parts
of the solution exists somewhere?



Thanks in advance,

Michael








_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://lists.roaringpeng
Dianne Skoll
2017-09-25 18:09:12 UTC
Permalink
On Mon, 25 Sep 2017 10:46:01 -0700
Post by Michael Fox
I'd like to be able to deliver HTML and Base64 messages to those clients.
You can do it by throwing away non-text/plain parts where a text/plain part
exists. Decoding base-64 is simply a matter of rewriting the attachment
and forcing the encoding to be quoted-printable. (I wouldn't recommend 7bit
encoding because that could be lossy.)

All of this is possible with MIME::tools and MIMEDefang, but as usual with
my replies, the details are left to the reader. :)

Your first point of departure should be: man MIME::Entity

Regards,

Dianne.
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/
Kees Theunissen
2017-09-26 00:49:41 UTC
Permalink
Post by Dianne Skoll
On Mon, 25 Sep 2017 10:46:01 -0700
Post by Michael Fox
I'd like to be able to deliver HTML and Base64 messages to those clients.
You can do it by throwing away non-text/plain parts where a text/plain part
exists.
Be careful with that. In an ideal world "multipart/alternative" MIME
parts would supply differently formatted versions of the same message.
But I have seen way too much messages where the plain text version
is only used to inform me that my mail client doesn't support html-mail.

A particular sender "Nederlandse Spoorwegen" (Dutch Railways) comes
in my mind, but there might be other brain death senders.

A typical message structure:

From: ....
To: ....
Date: ....
Subject: ....
Message-ID: ....
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_Part_4211042_445498562.1498036383123"

------=_Part_4211042_445498562.1498036383123
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Dear reader,

Your email program does not support HTML mail. Follow the link below
for the online version of this email so that you can read this email.

< some URL inserted here >

Sincerely,
Dutch railways

------=_Part_4211042_445498562.1498036383123
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

< html version of the message inserted here. >

------=_Part_4211042_445498562.1498036383123--


Ofcourse my mail client does support html mail, I only configured it to
prefere the plain text version.
Do I need to say that the URL mentioned in the plain text part is only
valid for a few months?

This migth not be a problem in most cases as the text/plain part
generally _is_ a valid representation of the message, but be aware that
you risk to delete unique contents when you throw away a non-text/plain
message part.


Regards,

Kees Theunissen.
--
Kees Theunissen, System and network manager, Tel: +31 (0)40-3334724
Dutch Institute For Fundamental Energy Research (DIFFER)
e-mail address: ***@differ.nl
postal address: PO Box 6336, 5600 HH, Eindhoven, the Netherlands
visitors address: De Zaale 20, 5612 AJ, Eindhoven, the Netherlands

_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://
Dianne Skoll
2017-09-26 13:25:48 UTC
Permalink
On Tue, 26 Sep 2017 09:05:01 +0200 (CEST)
Honestly, I would de-MIME the whole message, re-format it and replace
the entire message with the new one.
Honestly, *I* would tell anyone using ancient non-MIME-aware software
"too bad; update your software to 1999 standards, please!" :)

Regards,

Dianne.
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://lists
Bill Cole
2017-09-26 20:25:42 UTC
Permalink
Post by Kees Theunissen
Post by Dianne Skoll
On Mon, 25 Sep 2017 10:46:01 -0700
Post by Michael Fox
I'd like to be able to deliver HTML and Base64 messages to those clients.
You can do it by throwing away non-text/plain parts where a
text/plain part
exists.
Be careful with that. In an ideal world "multipart/alternative" MIME
parts would supply differently formatted versions of the same message.
But I have seen way too much messages where the plain text version
is only used to inform me that my mail client doesn't support
html-mail.
A particular sender "Nederlandse Spoorwegen" (Dutch Railways) comes
in my mind, but there might be other brain death senders.
There certainly are. Apropos to Mr. Fox's specific mention of Sprint,
here's what I get as the Base64-encoded text/plain part of a
multipart/alternative message every month:


Sprint(R)

Sprint sent you a plain text email because your settings do not
allow for images.

This is an account related email.

You are receiving this email because your bill is ready to view
online. Visit sprint.com/mysprint to make payments, view your bill
and more.

If you have questions about your bill, please visit
sprint.com/contactus.

To contact Sprint, write to:
Office of Privacy - Legal Department, Sprint,
P.O. Box 4600, Reston, Virginia, 20195.



The text/html alternative part contains the full text of my bill.

_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listi
Michael Fox
2017-09-27 04:53:14 UTC
Permalink
Post by Michael Fox
I'd like to be able to deliver HTML and Base64 messages to those clients.
Honestly, I would de-MIME the whole message, re-format it and replace the
entire message with the new one.
Yes, that makes sense.

Does there exist a repository of functions written by folks for MD? It sure would help us noobs to not have to re-invent the wheel.

Michael



_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://lists.roari
Dianne Skoll
2017-09-27 12:15:14 UTC
Permalink
On Tue, 26 Sep 2017 21:53:14 -0700
Post by Michael Fox
Does there exist a repository of functions written by folks for MD?
It sure would help us noobs to not have to re-invent the wheel.
MIME::tools is what you want; it's a prerequisite for MIMEDefang
and is therefore already installed. man MIME::Entity is your
starting point.

Regards,

Dianne.
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID. You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list ***@lists.roaringpenguin.com
http://lists.r

Loading...