geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maho77 <>
Subject Re: Encoding problem in geronimo-javamail implementation
Date Mon, 02 Jun 2008 11:59:12 GMT

Rick McGuire wrote:
> maho77 wrote:
>> Hello,
>> it seems to me that the geronimo javamail implementation has some
>> encoding
>> problems. I use G2.1.1
>> I retrieve Message via POP3 and than I start parsing the parts in the
>> Message class. Everything works fine as long as I the mails are UTF-8
>> mails.
>> If there's an mail lets say with ISO-8859-1 the subject has the correct
>> encoding conversion, but not the content of the parts.
>> If I try the same with the javamail implementation from sun, it works
>> well.
>> Do I have to set some properties or something like that?
> This sounds like it's just a bug to me.  The POP3 implementation is 
> fairly new, and it's entirely possible there are some problems with 
> encodings....particularly since the javamail API docs are not entirely 
> clear on how some features should work.  If you can post a small sample 
> that can be run against both implementations, I'll gladly take a look at 
> it.
> Rick
>> Mark

you need an email with e.g. ISO-8859-1 or ISO-8859-15 encoding
write in the subject: Test Ä-Ü-Ö
write the same in the body: Test Ä-Ü-Ö
check if it's a plain-text mail (it's easier to read this mail.

Retrieve this mail using the geronimo-mailapi. You can doublecheck the
result trying the sun javamail implementation. 
The subject ending is converted correctly. I think this is a result of bug:
GERONIMO-3842. But the encoding of the message-part only works with UTF-8.
There is no correct conversion to other charsets like ISO-8859-1.
This is how to receive the message and write into a file:
		Store store;
		Properties props = new Properties();
		Session session = Session.getInstance(props);
		FileOutputStream fos = null;
		try {
			store = session.getStore("pop3");
			store.connect(SERVER, USERNAME, PASSWORD);
			// Get folder
			Folder folder = store.getFolder("INBOX");;
			// Get directory
			Message messages[] = folder.getMessages();
			for (int i = 0; i < messages.length; i++) {
				ByteArrayOutputStream baos = new ByteArrayOutputStream();
				// write mail into a file
				File file = new File("path_to_file");
				fos = new FileOutputStream(file);
		} catch (NoSuchProviderException e) {
		} catch (MessagingException e) {
		} catch (Exception e) {
		} finally { 
			if ( fos != null ) 
		        try { fos.close(); } catch ( IOException e ) { } 

This is a sample mail created with mozilla thunderbirs:
>From - Fri May 30 15:59:50 2008
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00800000
Message-ID: <>
Date: Fri, 30 May 2008 15:59:50 +0200
From: Mark Hoffmann <>
User-Agent: Thunderbird (X11/20080226)
MIME-Version: 1.0
Subject: test =?ISO-8859-1?Q?=F6=E4=F6=FC?=
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Test öäü

I hope this helps,

View this message in context:
Sent from the Apache Geronimo - Users mailing list archive at

View raw message