*/
public void sendPlain(String from, String to, String cc, String bcc, String bounceAddress, String replyTo, String subject, String content, String encoding) throws SystemException
{
try
{
SimpleEmail email = new SimpleEmail();
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(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.setMsg(content);
email.send();
}
catch (Exception e)
{
logger.error("An error occurred when we tried to send this mail:" + e.getMessage(), e);
}