Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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: <1317977606.4e8ebe06ceab7@myserver.local>
Date: Fri, 07 Oct 2011 10:53:26 +0200
Subject: Registrierung
From: me@me.com
To: tt99@example.com
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.

share|improve this question
    
Could you please show an example? –  quanta Oct 7 '11 at 9:12
    
I'm still confused. Please make clear your first point and give us the expected output? –  quanta Oct 7 '11 at 10:32

2 Answers 2

up vote 3 down vote accepted

Ok, answering my own question here, based on some googling and the helpful comments by mailq.

In short: I installed and used mutt. I had to fiddle a bit with my setup: Inside the directory my_dir where fakemail was creating the mail files, I created the dirs new, cur and tmp and pointed fakemail to my_dir/new. Then I started mutt with

mutt -f my_dir

Now I can review new mails, look at old mails, the umlauts are properly displayed - perfect!

share|improve this answer

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).

share|improve this answer
1  
I thought there would already exist a simple command line program for it. Is my problem really this exotic that i have to write my own? –  chiborg Oct 7 '11 at 12:20
1  
Oh, you mean mutt? Why didn't you write that you are looking for a command-line mail client? –  mailq Oct 7 '11 at 12:35
1  
Well, yes. I looked into mutt but did not find the right command line to just open one mail file. My folder with the mail files is not a real maildir (no subfolders, weird naming of messages), so all the usual "How to configure mutt" tutorials don't apply. If your can point out to me how to use a shell mail program to read a single file in a directory of mail files, I would be very happy. –  chiborg Oct 10 '11 at 12:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.