`
Ben.Sin
  • 浏览: 233127 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Javamail在解析附件是抛出Missing start boundary异常

    博客分类:
  • Java
阅读更多

在做javamail通过pop3解析邮件的时候,在解析邮件包含附件的时候,在测试服务器上出现了以下异常

 

Missing start boundary

 

javax.mail.MessagingException: Missing start boundary
	at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:297)
	at javax.mail.internet.MimeMultipart.getCount(MimeMultipart.java:159)
	at com.gdcn.mail.util.Pop3Util.getAttachments(Pop3Util.java:1937)
	at com.gdcn.mail.util.Pop3Util.analysisMessage(Pop3Util.java:1455)
	at com.gdcn.mail.util.Pop3Util.getMessages3(Pop3Util.java:611)
	at com.gdcn.mail.service.impl.MailServicePop3Impl.fetchMail(MailServicePop3Impl.java:68)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy6.fetchMail(Unknown Source)
	at com.gdcn.mail.push.FetchMailTask.run(FetchMailTask.java:31)
	at com.gdcn.mail.push.ThreadPool$PoolWorker.run(ThreadPool.java:223)

 

出现异常的邮件

HMM_SOURCE_IP: 10.27.101.6:46499.1351811048
HMM_ATTACHE_NUM: 0002
HMM_SOURCE_TYPE: SMTP
Received: from entas6-mta (unknown [10.27.101.6]) by corp.21cn.com (HERMES) with ESMTP id 79F701A4821 for <gdcm@gdccs.com.cn>; Tue,  1 Sep 2009 17:21:40 +0800 (CST)
Received: from m13-86.163.com([220.181.13.86]) by entas6-mta(Knowledge-based Antispam Gateway 2.127s34(2009-06-12),121.14.129.76) with ESMTP id mx28123.1251796900 for <gdcm@gdccs.com.cn>; Tue, 01 Sep 2009 17:21:40 +0800
X-Original-MailFrom: mdbjz@163.com
Received: from mdbjz (  [59.41.140.125] ) by ajax-webmail-wmsvr86 (Coremail) ; Tue, 1 Sep 2009 17:21:37 +0800 (CST)
Date: Tue, 1 Sep 2009 17:21:37 +0800 (CST)
From: =?GBK?B?sPy93NbQ?= <mdbjz@163.com>
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
To: "gdcm" <gdcm@gdccs.com.cn>
Message-ID: <18639209.356941251796897159.JavaMail.coremail@bj163app86.163.com>
Subject: =?GBK?B?WyEhIFNQQU1dICA1MMz1suLK1Mr9vt28sNbcsagov6q3ormry74p?=
MIME-Version: 1.0
Content-Type: multipart/mixed;
	boundary="----=_NextPart_000_F2CD_01CA2CBB.C11696B0"
X-Originating-IP: [59.41.140.125]
X-Priority: 1
X-Mailer: Coremail Webmail Server Version XT2_snapshot build 090721(8334.2507.2500) Copyright (c) 2002-2009 www.mailtech.cn 163com
X-CM-CTRLDATA: AojLYWZvb3Rlcl9odG09NTM6MTIy
X-CM-TRANSID: VsGowLB7TgKh55xK0OEWAQ--.13413W
X-CM-SenderInfo: hpgey6i6rwjhhfrp/1tbiSRjQp0iZZ8PSFwAAsW
X-Coremail-Antispam: 1Ur529EdanIXcx71UUUUU7IcSsGvfJTRUUUbk8YjxAI67I2x7xF5VA2z7Wlb7IF0VA0xI801c0E3s0DM7k042IE42xK82IY6r43WwAYjxAI6xAIw28IcVAK0I8IjxAxM7k042IE4IIF72xFxVCS07vE4c8EcI0En4kS14v7M7k042IE4IIF72xFxVCS07vE4c8EcI0Ec7CjxVAaw2AFwI1ln4vEc-sFP3VYkVCFn4kS6r1kJF4UZwAa7VASz4kS-IxE6c8GOVWUur1xGFWl57IF6s8CjcxG0xylFVAaXTZC67ZELSn0mTvEwaV2v3VFvVW8M4kE7xkE3sIEV2x5Mx0Yzs0v6IAIbVCF54CYxVAaw2AFwI1l7xkE3sIEV2xY6xAqzxv26xkF7I0En4kS14v7MxCIbVA2zIxYr2IEbsI20wCS07vEb7Iv0xC_Jr1lV2xY67kC6x804xWlV2xY67AvxsIEeIx0w2Cm54CxMIAIbVAFxVCF77xC64kEw24lV2xY67C26IkvcIIF6IxKo4kEV4ylV2xY62AExVA0xI801c8C04v7MIAIbVAqx4xG64xvF2IEw4CE5I8CrVC2j2WlV2xY6cIj6x8ErcxFaVAv8VWUMIAIbVAv7VC0I7IYx2IY67AKxVWUAVWUtwCS07vEYx0Ex4A2jsIE14v26F4j6r4UJwCS07vE7480Y4vEI4kI2Ix0rVAqx4xJMIAIbVCjxxvEw4WlV2xY6xkIecxEwVAFwVW8uwCS07vEc2IjII80xcxEwVWxJVW3JwCS07vE4c8EcI0En4kS14v26rWUJr0E3s0q3wCS07vE4c8EcI0Ec7CjxVAaw2AFwI0_Ar1UJVCq3s0DMIAIbVCF72vE77IF4wCS07vEx4CE17CEb7AF67AKxVWUJVWUXbIYCTnIWIevJa73U

This is a multi-part message in MIME format.

------=_NextPart_000_F2CD_01CA2CBB.C11696B0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_F2CE_01CA2CBB.C11696B0"


------=_NextPart_001_F2CE_01CA2CBB.C11696B0
Content-Type: text/plain;
	charset="gbk"
Content-Transfer-Encoding: base64

CgoKCgog
------=_NextPart_001_F2CE_01CA2CBB.C11696B0
Content-Type: text/html;
	charset="gbk"
Content-Transfer-Encoding: base64

PERJVj48QlI+PEJSPjwvRElWPgo8RElWPjxCUj4KPERJVj4mbmJzcDs8L0RJVj48L0RJVj48YnI+
PGJyPjxzcGFuIHRpdGxlPSJuZXRlYXNlZm9vdGVyIi8+PGhyLz4KPGEgaHJlZj0iaHR0cDovL3d3
dy55ZWFoLm5ldC8/ZnJvbT1mb290ZXIiPsO709C547jmtcTW1cntw+K30dPKz+Qsd3d3LnllYWgu
bmV0PC9hPgo8L3NwYW4+
------=_NextPart_001_F2CE_01CA2CBB.C11696B0--

------=_NextPart_000_F2CD_01CA2CBB.C11696B0
Content-Type: application/vnd.ms-excel;
	name="=?GBK?B?uL28/jctus/NrM/uxL/K/b7dytW8r7HtKL2ov6opLnhscw==?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="=?GBK?B?uL28/jctus/NrM/uxL/K/b7dytW8r7HtKL2ov6opLnhscw==?="

0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAA
EAAAMQEAAAEAAAD+////AAAAAAAAAABiAAAA8QAAAP//////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////9
////NAEAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8A
AAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAA
AB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACQAAAAlAAAAJgAAACcAAAAoAAAAKQAAACoAAAArAAAA
LAAAAC0AAAAuAAAALwAAADAAAAAxAAAAMgAAADMAAAA0AAAANQAAADYAAAA3AAAAOAAAADkAAAA6
AAAAOwAAADwAAAA9AAAAPgAAAD8AAABAAAAAQQAAAEIAAABDAAAARAAAAEUAAABGAAAARwAAAEgA
AABJAAAASgA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AAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
------=_NextPart_000_F2CD_01CA2CBB.C11696B0--
 

 

但是这个在本机并没有这样的异常出现。网上查了不少帖子,真正能解决这个问题不多。

 

不过有个帖子给了我点提示

 

http://forums.sun.com/thread.jspa?forumID=43&threadID=5152319

 

后来部署到另外一台测试机器上发现能正常解析,于是停掉了原来测试机的杀毒软件,就能正常解析出来了

 

不过也在解析的时候首先判断了message是否继承与Part接口的

 

部分节选代码如下

		try {
			if (msg instanceof Part){
				Part part = (Part) msg;
	
				if (part.isMimeType("multipart/*")) {
					Multipart mp = (Multipart) part.getContent();
					System.out.println(mp);
					int count = mp.getCount();
	
					for (int i = 0; i < count; i++) {
						Part p = mp.getBodyPart(i);
						//某些处理
					}
	
					mp = null;
				}
			}
		} catch (MessagingException e) {
...省略
 

 

 

分享到:
评论

相关推荐

    javamail 邮件解析、接收、发送程序

    很好的邮件处理代码,1.5版本,作为build path放在eclipse里面,就可以用啦! oracle官方推的,很好!jdk1.6版本以上用起来很方便。

    javamail收取邮件(包括附件)

    在JavaMail中,我们可以利用其API来实现邮件的收发功能,包括处理附件。下面我们将详细探讨如何使用JavaMail API实现邮件的收取,特别是如何通过POP3和IMAP协议获取邮件信息。 首先,确保你的项目中已经引入了...

    JavaMail(3)——发送带附件的邮件.docx

    在JavaMail中,发送带有附件的邮件涉及到对MIME(Multipurpose Internet Mail Extensions)标准的理解和使用。MIME扩展了邮件协议,允许在邮件中包含多媒体内容,如图片、文档、音频或视频文件等。 在JavaMail中,`...

    javamail邮件解析

    JavaMail邮件解析是Java开发中处理电子邮件的一种常见方式,它允许开发者通过编程接口与邮件服务器进行交互,实现发送、接收和解析邮件的功能。在JavaMail中,`Mail`类通常是自定义封装邮件操作的核心类。以下是对这...

    javamail附件从流中获取

    在"javamail附件从流中获取"这个主题中,我们将深入探讨如何使用JavaMail库从输入流中读取数据并作为邮件附件发送。 首先,我们需要导入JavaMail的相关库,主要包含`javax.mail`和`com.sun.mail`两个包。这两个包...

    JavaMail发送带附件的邮件

    在JavaMail中发送带附件的邮件是一个常见的需求,尤其对于企业级应用或者自动化任务来说。下面将详细介绍如何使用JavaMail来实现这一功能,以及所需依赖和示例代码。 首先,要使用JavaMail,你需要在项目中添加相应...

    javaMail 全功能 附件 HTML

    javaMail可以代附件,可以发送HTML,可以在HTML只显示图片等

    javamail 可带附件demo 源码

    JavaMail 是一个开源库,它提供了在Java应用程序中发送和接收电子邮件的标准API。这个源码示例是关于如何使用JavaMail来发送带有附件的邮件。JavaMail API 遵循JSR 54规范,使得开发者能够处理复杂的邮件功能,如...

    james和javamail实现邮件收发(带发送附件)

    在这个例子中,我们将深入探讨如何利用James服务器和JavaMail API来实现这一目标,同时处理中文内容和附件。 首先,James(Apache James)是一个开源的邮件服务器,它支持SMTP、POP3和IMAP协议,可以作为企业级的...

    javaMail 用三种方式实现发送附件

    javaMail 用附件路径,文件流 byte[] 或 base64 字符串 实现发送附件功能

    06 使用JavaMail发送带附件的邮件.exe

    06 使用JavaMail发送带附件的邮件.exe06 使用JavaMail发送带附件的邮件.exe

    JavaMail发送给多人,添加多个附件

    javaMail

    javamail(带界面的javamail)

    JavaMail 是一个强大的开源库,用于在Java应用程序中实现电子邮件的发送和接收功能。它提供了丰富的API,使得开发者能够方便地处理SMTP、POP3、IMAP等邮件协议,支持多种邮件格式,包括文本、HTML以及带有附件的邮件...

    javamail 所有jar包

    JavaMail 是一个开源的 Java API,它为开发者提供了在 Java 应用程序中发送和接收电子邮件的功能。这个API包括了多种协议的支持,如SMTP(简单邮件传输协议)、POP3(邮局协议)和IMAP(因特网消息访问协议)。在...

    Gmail邮件通过JavaMail发送(不带附件与带一个附件)

    本教程将详细讲解如何使用JavaMail API在Gmail上发送邮件,包括不带附件和带有一个附件的情况。 首先,JavaMail是一个开源的Java库,它提供了用于处理邮件的标准API。在使用JavaMail发送邮件前,你需要在项目中引入...

    JavaMail 1.5.2

    10. **异常处理**:在处理邮件时,JavaMail 抛出一系列的异常,如 `MessagingException`、`AddressException` 和 `AuthenticationFailedException` 等,开发者需要适当地捕获和处理这些异常,以确保程序的健壮性。...

    JavaMail+JAF+JavaMail_API+JavaMail_API详解

    在JavaMail中,JAF被用来解析和操作邮件中的复杂数据结构,如带有附件或嵌入图片的邮件。jaf-1_1_1.zip文件包含了JAF的1.1.1版本,可能包括了库文件、API文档和其他相关资源。 JavaMail API documentation.rar可能...

    怎么用JavaMail收取邮件

    JavaMail 是一个强大的开源库,用于在 Java 应用程序中处理电子邮件的发送与接收。在本文中,我们将深入探讨如何使用 JavaMail 收取邮件,包括了解 POP3 和 IMAP 协议以及如何通过 JavaMail API 实现邮件的接收。 ...

    JAVAMAIL集合发送图片,附件,内容,HTML等得JAVAMAIL代码

    本资源是一个集合发送图片,附件,内容,HTML等得JAVAMAIL代码,并且可以同时发送多个附件多个图片,只需填充VO类,即可直接调用并发送邮件,例子已经写好,只要填充上必要值即可,经163,qq,sina测试没有问题,有...

    JavaMail相关Jar包

    在JavaMail中,JAF用于解析和操作MIME消息,包括读取和写入MIME类型的附件。没有JAF,JavaMail可能无法正确处理某些复杂的邮件格式,比如包含图像或其他多媒体附件的邮件。 以下是一个使用JavaMail发送邮件的基本...

Global site tag (gtag.js) - Google Analytics