public static MockMimeMessage createMimeMessage(String headerName, String headerValue, String subject, int number)
throws MessagingException {
String sender = "test@james.apache.org";
String rcpt = "test2@james.apache.org";
MockMimeMessage mockedMimeMessage = new MockMimeMessage(number);
mockedMimeMessage.setFrom(new InternetAddress(sender));
mockedMimeMessage.setRecipients(MimeMessage.RecipientType.TO, rcpt);
if (headerName != null) {
mockedMimeMessage.setHeader(headerName, headerValue);
}
if (subject != null) {
mockedMimeMessage.setSubject(subject);
}
mockedMimeMessage.setText("testtext");
mockedMimeMessage.saveChanges();
return mockedMimeMessage;
}