Mail server: James. Mail container: Maria DB
Mail parsing source is like below:
Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: from 192.168.10.159 ([192.168.10.159])
by WIN-55ERUE9ID5R (JAMES SMTP Server 2.3.2) with SMTP ID 374
for <[email protected]>;
Sat, 14 Nov 2015 16:08:06 +0900 (KST)
Received: from unknown (HELO cas01.bsecm.com) (192.168.10.14)
by 192.168.10.159 with ESMTP; 14 Nov 2015 16:07:48 +0900
X-Original-SENDERIP: 192.168.10.14
X-Original-MAILFROM: [email protected]
X-Original-RCPTTO: [email protected]
Resent-From: <[email protected]>
Received: from spam.bsecm.com (192.168.10.159) by cas01.bsecm.com
(192.168.10.14) with Microsoft SMTP Server (TLS) id 14.3.224.2; Sat, 14 Nov
2015 16:07:42 +0900
Received: from unknown (HELO ?219.255.136.51?) (219.255.136.51) by
192.168.10.159 with ESMTP; 14 Nov 2015 16:07:47 +0900
X-Original-SENDERIP: 219.255.136.51
X-Original-MAILFROM: [email protected]
X-Original-RCPTTO: [email protected]
Date: Sat, 14 Nov 2015 16:07:56 +0900
Subject: =?euc-kr?B?W0tCxKu15Vdpc2VJbmZvIMfDt6+9ul3AscDnyKO01MDHIDExv/kgvcW/68Gkurizu7+qvK3A1LTPtNku?=
From: =?euc-kr?B?v8PFqbe5tfc=?= <[email protected]>
To: <[email protected]>
Reply-To: <[email protected]>
MIME-Version: 1.0
Content-Transfer-Encoding: BASE64
X-Mailer: Netpion Service Server v3.0.0
X-NetpionMsgID: 1447484876647.10284.1455.759978089,KB06,1006190838.1
Content-Type: multipart/mixed;
boundary="--Netpathy_Netpion.1447484876647.AA"
Message-ID: <[email protected]>
LS0tLU5ldHBhdGh5X05ldHBpb24uMTQ0NzQ4NDg3NjY0Ny5BQQ0KQ29udGVudC1UeXBlOiBtdWx0
aXBhcnQvYWx0ZXJuYXRpdmU7DQoJYm91bmRhcnk9Ii0tTmV0cGF0aHlfTmV0cGlvbi4xNDQ3NDg0
ODc2NjQ3LlpaIg0KDQotLS0tTmV0cGF0aHlfTmV0cGlvbi4xNDQ3NDg0ODc2NjQ3LlpaDQpDb250
NEthVzVwZENncE93bzgNCkwzTmpjbWx3ZEQ0PQ0KDQotLS0tTmV0cGF0aHlfTmV0cGlvbi4xNDQ3
NDg0ODc2NjQ3LkFBLS0NCg==
- The contents is encoded by BASE64. At "Content-Transfer-Encoding: BASE64".
- When I get contents Java tells me "Missing start boundary" exception.
byte[] messageBody = (byte[])("*FROM DB BLOB DATA*"); Message jamesMail = new MimeMessage(session, new ByteArrayInputStream(messageBody) ); Multipart mp = (Multipart)jamesMail.getContent(); int i = mp.getCount();
- And now I decode mail contents. This can parse mail contents to be readable.
java.io.InputStream is = jamesMail.getInputStream(); java.io.InputStream decodedIs = MimeUtility.decode(is, contentTransferEncoding); mp = (Multipart)ms.getContent(); for(int m=0; m < mp.getCount(); m++){ // contents text processing // attached file processing }
But, mail contents has an attached file with encoded by BASE64. And my code can not parse that attached file.
Question -. How can I parsing pre-encoded mail contents using Javamail? -. How can I parsing pre-encoded attachment file?