On my Linux development system I use fakemail to write mails to a directory instead of sending them. The mail files contain the headers and the text of the mail as quoted-printable, text/plain in UTF-8. How can I read a single mail file and "decode" the quoted-printable so line breaks and special chars show up correctly?
Here is an example of a German mail file with line breaks and special chars:
Message-ID: <[email protected]>
Date: Fri, 07 Oct 2011 10:53:26 +0200
Subject: Registrierung
From: [email protected]
To: [email protected]
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Hallo,
Sie haben sich auf Meinserver.de als Benutzer regist=
riert. Um Ihre
Registrierung abzuschlie=C3=9Fen, klicken Sie auf folg=
enden Link:
http://meinserver.de/benutzer/bestaetigen/3lk6lp=
ga1kcgcg484kc8ksg
I want the special chars to be replaced with their proper counterparts and the line breaks inserted by the quoted-printable encoding (the ones with a "=" at the end) removed.
The answer is: Just do it.
Either use APIs in your preferred programming language to parse MIME messages and decode quoted-printable and base64. Or you do it on your own by writing software implementing the linked standards.
Both options work. Pick the right and go for it. (Then look at Stackoverflow for details as this is out of the scope of Serverfault).