I'm writing test for my process mail app. I'm using greenmail for testing and everything works just fine when I send mime multipart message( html or text). But when I try to send a message with an attachment(because I need a message with attachment to test my methods for processing). I receive this error. Any idea why is this happening? Otherwise there is no problem with receiving and sending emails.
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);
}
}