*/
public void sendHTML(String from, String to, String cc, String bcc, String bounceAddress, String replyTo, String subject, String content, String encoding) throws SystemException
{
try
{
HtmlEmail email = new HtmlEmail();
String mailServer = CmsPropertyHandler.getMailSmtpHost();
String mailPort = CmsPropertyHandler.getMailSmtpPort();
String systemEmailSender = CmsPropertyHandler.getSystemEmailSender();
email.setHostName(mailServer);
if(mailPort != null && !mailPort.equals(""))
email.setSmtpPort(Integer.parseInt(mailPort));
boolean needsAuthentication = false;
try
{
needsAuthentication = new Boolean(CmsPropertyHandler.getMailSmtpAuth()).booleanValue();
}
catch (Exception ex)
{
needsAuthentication = false;
}
if (needsAuthentication)
{
final String userName = CmsPropertyHandler.getMailSmtpUser();
final String password = CmsPropertyHandler.getMailSmtpPassword();
email.setAuthentication(userName, password);
}
email.setBounceAddress(systemEmailSender);
email.setCharset(encoding);
if(logger.isInfoEnabled())
{
logger.info("systemEmailSender:" + systemEmailSender);
logger.info("to:" + to);
logger.info("from:" + from);
logger.info("mailServer:" + mailServer);
logger.info("mailPort:" + mailPort);
logger.info("cc:" + cc);
logger.info("bcc:" + bcc);
logger.info("replyTo:" + replyTo);
logger.info("subject:" + subject);
}
if(to.indexOf(";") > -1)
{
cc = to;
to = from;
}
String limitString = CmsPropertyHandler.getEmailRecipientLimit();
if(limitString != null && !limitString.equals("-1"))
{
try
{
Integer limit = new Integer(limitString);
int count = 0;
if(cc != null)
count = count + cc.split(";").length;
if(bcc != null)
count = count + bcc.split(";").length;
logger.info("limit: " + limit + ", count: " + count);
if(count > limit)
throw new Exception("You are not allowed to send mail to more than " + limit + " recipients at a time. This is specified in app settings.");
}
catch (NumberFormatException e)
{
logger.error("Exception validating number of recipients in mailservice:" + e.getMessage(), e);
}
}
email.addTo(to, to);
email.setFrom(from, from);
if(cc != null)
email.setCc(createInternetAddressesList(cc));
if(bcc != null)
email.setBcc(createInternetAddressesList(bcc));
if(replyTo != null)
email.setReplyTo(createInternetAddressesList(replyTo));
email.setSubject(subject);
email.setHtmlMsg(content);
//email.setTextMsg(Jsoup.parse(content).text());
email.send();
logger.info("Email sent!");
}
catch (Exception e)
{