{
this.getMailServer();
String strSubject = "Test HTML Send #1 Subject (w charset)";
this.email = new MockHtmlEmailConcrete();
this.email.setHostName(this.strTestMailServer);
this.email.setSmtpPort(this.getMailServerPort());
this.email.setFrom(this.strTestMailFrom);
this.email.addTo(this.strTestMailTo);
/** File to used to test file attachmetns (Must be valid) */
attachment.setName("Test Attachment");
attachment.setDescription("Test Attachment Desc");
attachment.setPath(testFile.getAbsolutePath());
this.email.attach(attachment);
this.email.setAuthentication(this.strTestUser, this.strTestPasswd);
this.email.setCharset(Email.ISO_8859_1);
this.email.setSubject(strSubject);
URL url = new URL(EmailConfiguration.TEST_URL);
String cid = this.email.embed(url, "Apache Logo");
String strHtmlMsg =
"<html>The Apache logo - <img src=\"cid:" + cid + "\"><html>";
this.email.setHtmlMsg(strHtmlMsg);
this.email.setTextMsg(
"Your email client does not support HTML emails");
this.email.send();
this.fakeMailServer.stop();
// validate txt message
validateSend(
this.fakeMailServer,
strSubject,
this.email.getTextMsg(),
this.email.getFromAddress(),
this.email.getToList(),
this.email.getCcList(),
this.email.getBccList(),
true);
// validate html message
validateSend(
this.fakeMailServer,
strSubject,
this.email.getHtmlMsg(),
this.email.getFromAddress(),
this.email.getToList(),
this.email.getCcList(),
this.email.getBccList(),
false);
// validate attachment
validateSend(
this.fakeMailServer,
strSubject,
attachment.getName(),
this.email.getFromAddress(),
this.email.getToList(),
this.email.getCcList(),
this.email.getBccList(),
false);
}
catch (Exception e)
{
fail("Unexpected exception thrown");
}
try
{
this.getMailServer();
this.email = new MockHtmlEmailConcrete();
this.email.setHostName(this.strTestMailServer);
this.email.setSmtpPort(this.getMailServerPort());
this.email.setFrom(this.strTestMailFrom);
this.email.addTo(this.strTestMailTo);