attachment.setPath(testFile.getAbsolutePath());
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setName("Test_Attachment");
attachment.setDescription("Test Attachment Desc");
MockMultiPartEmailConcrete testEmail =
new MockMultiPartEmailConcrete();
testEmail.setHostName(this.strTestMailServer);
testEmail.setSmtpPort(this.getMailServerPort());
testEmail.setFrom(this.strTestMailFrom);
testEmail.addTo(this.strTestMailTo);
testEmail.attach(attachment);
testEmail.setSubType("subType");
if (EmailUtils.isNotEmpty(this.strTestUser)
&& EmailUtils.isNotEmpty(this.strTestPasswd))
{
testEmail.setAuthentication(
this.strTestUser,
this.strTestPasswd);
}
testEmail.setSubject(strSubject);
testEmail.setMsg("Test Message");
Hashtable ht = new Hashtable();
ht.put("X-Priority", "2");
ht.put("Disposition-Notification-To", this.strTestMailFrom);
ht.put("X-Mailer", "Sendmail");
testEmail.setHeaders(ht);
testEmail.send();
this.fakeMailServer.stop();
// validate message
validateSend(
this.fakeMailServer,
strSubject,
testEmail.getMsg(),
testEmail.getFromAddress(),
testEmail.getToList(),
testEmail.getCcList(),
testEmail.getBccList(),
true);
// validate attachment
validateSend(
this.fakeMailServer,
strSubject,
attachment.getName(),
testEmail.getFromAddress(),
testEmail.getToList(),
testEmail.getCcList(),
testEmail.getBccList(),
false);
}
catch (IOException e)
{