我正在为我的流程邮件应用编写测试。我正在使用greenmail进行测试,当我发送mime multipart消息(html或文本)时,一切正常。但是当我尝试发送带附件的消息时(因为我需要带附件的消息来测试我的方法进行处理)。我收到此错误。知道为什么会这样吗?否则接收和发送电子邮件都没有问题。
Exception in thread "Thread-7" java.lang.RuntimeException: java.io.EOFException: Did not receive <CRLF>.<CRLF>
at com.icegreen.greenmail.smtp.SmtpHandler.run(SmtpHandler.java:58)
at com.icegreen.greenmail.server.AbstractServer$1.run(AbstractServer.java:101)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.EOFException: Did not receive <CRLF>.<CRLF>
at com.icegreen.greenmail.mail.MovingMessage.readDotTerminatedContent(MovingMessage.java:107)
at com.icegreen.greenmail.smtp.commands.DataCommand.execute(DataCommand.java:55)
at com.icegreen.greenmail.smtp.SmtpHandler.handleCommand(SmtpHandler.java:97)
at com.icegreen.greenmail.smtp.SmtpHandler.run(SmtpHandler.java:51)
... 2 more
and part of my code where I compose the message.
List<String> attachList = new ArrayList<String>();
attachList
.add("/home/testattachments/attachment.txt");
private void createAttachPart(List<String> attachList,
Multipart multipart) throws MessagingException, IOException {
for (String path : attachList) {
MimeBodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.attachFile(path);
messageBodyPart.setFileName(new File(path).getName());
messageBodyPart.setDisposition(MimePart.ATTACHMENT);
multipart.addBodyPart(messageBodyPart);
}
}