JavaMail is losing some POP3 message headers and treats multipart/mixed as text/plain
-
29-06-2021 - |
Question
I am having a strange issue parsing some POP3 messages in JavaMail 1.4.4 - Java 1.4, also in Java 1.6.
I am parsing a com.sun.mail.pop3.POP3Message
retrieved from a Windows 2003 POP3 service mailbox. When I go through the getAllHeaderLines()
Enumeration and compare them to the source message I see that the Reply-To header is cut off in mid email address and all remaining headers are missing (specifically Subject, To, In-Reply-To, MIME-Version, Contact-Type, Return-Path and X-OriginalArrivalTime). The getContentType()
method returns text/plain and the getContent()
method returns the entire multipart/mixed message as a String.
Everything about the message looks normal and matches the source message file when I turn on JavaMail debug mode.
Any ideas would be appreciated.
Here is a snippet from the source message file in the POP3 mailbox:
Message-ID: <1345995532.54860.YahooMailNeo@web111910.mail.gq1.yahoo.com>
Date: Sun, 26 Aug 2012 08:38:52 -0700
From: Secure Comfort <securecomforttransportation@ymail.com>
Reply-To: Secure Comfort <securecomforttransportation@ymail.com>
Subject: Language & Transportation Service
To: "xxxxxx@xxxxxx.com"
< xxxxxx @ xxxxxx.com>
In-Reply-To: <1345995390.53486.YahooMailNeo@web111908.mail.gq1.yahoo.com>
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="1816409020-1433069823-1345995533=:54860"
Return-Path: securecomforttransportation@ymail.com
X-OriginalArrivalTime: 26 Aug 2012 15:39:22.0287 (UTC) FILETIME=[F6D67BF0:01CD83A0]
--1816409020-1433069823-1345995533=:54860
Content-Type: multipart/alternative;
boundary="1816409020-520494517-1345995533=:54860"
--1816409020-520494517-1345995533=:54860
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Here are most of the getters for the MimeMessage:
Content ID=null
Content Language=null
Content MD5=null
Content Type=text/plain
Data Handler=javax.mail.internet.MimeBodyPart$MimePartDataHandler
Description=null
Disposition=null
Encoding=null
File Name=null
Line Count=-1
Message ID=<1345995532.54860.YahooMailNeo@web111910.mail.gq1.yahoo.com>
Received Date=null
Sent Date=Sun Aug 26 10:38:52 CDT 2012
Size=7480850
Subject=null
Solution
What does the debug output from JavaMail show? (If you don't want to post it here, send it to me at javamail_ww@oracle.com.)
There's no header size limit in JavaMail.
Possibly you have a firewall or anti-virus software that's intercepting the conversation with the server and (accidentally) introducing this break in the message headers.