### Question:
MailErrorsManager implements ErrorsManager { Message prepareMessage(UserDataRequest udr, String subject, String body, InputStream errorMail) throws FileNotFoundException, IOException, ParseException { MessageImpl mm = prepareMessageHeaders(udr, subject); Multipart multipart = mime4jUtils.createMultipartMixed(); BodyPart part = mime4jUtils.createTextPart(body.toString(), "plain"); multipart.addBodyPart(part); mime4jUtils.attach(multipart, errorMail, "error_message.eml", "message/rfc822"); Map<String, String> params = mime4jUtils.getContentTypeHeaderParams(Charsets.UTF_8); String boundary = MimeUtil.createUniqueBoundary(); params.put(ContentTypeField.PARAM_BOUNDARY, boundary); mm.setBody(multipart, MimeContentType.MULTIPART_MIXED.getContentType(), params); return mm; } @Inject  MailErrorsManager(MailboxService manager, MailErrorsMessages messages, Mime4jUtils mime4jUtils,
			DateProvider dateProvider); @Override void sendMailHandlerError(UserDataRequest udr, byte[] errorMail, Throwable error); @Override void sendQuotaExceededError(UserDataRequest udr,
			QuotaExceededException e);  }### Answer:
@Test public void testPrepareMessage() throws ParseException, FileNotFoundException, IOException { User user = User.Factory.create().createUser("test@domain", "test@domain", "displayName"); UserDataRequest userDataRequest = new UserDataRequest(new Credentials(user, "password".toCharArray()), null, null); Mime4jUtils mime4jUtils = new Mime4jUtils(); MailErrorsManager errorsManager = new MailErrorsManager(null, null, mime4jUtils, dateProvider); Message message = errorsManager.prepareMessage(userDataRequest, "Subject", "Body", StreamMailTestsUtils.newInputStreamFromString("It's mail content !")); InputStream stream = mime4jUtils.toInputStream(message); String messageAsString = CharStreams.toString(new InputStreamReader(stream, Charsets.UTF_8)); assertThat(message).isNotNull(); assertThat(message.getDate()).isEqualTo(messageHeaderDate); assertThat(message.isMultipart()).isTrue(); assertThat(messageAsString).contains("test@domain") .contains("Subject: Subject") .contains("Body") .contains("Content-Disposition: attachment; filename=error_message.eml") .contains("It's mail content !"); }