Session mailSession = WebloggerStartup.getMailProvider() != null
? WebloggerStartup.getMailProvider().getSession() : null;
if(mailSession == null) {
throw new WebloggerException("ERROR: Notification email(s) not sent, "
+ "Roller's mail session not properly configured");
}
try {
UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
String userName = user.getUserName();
String from = website.getEmailAddress();
String cc[] = new String[] {from};
String bcc[] = new String[0];
String to[] = new String[] {user.getEmailAddress()};
String subject;
String content;
// Figure URL to entry edit page
String rootURL = WebloggerRuntimeConfig.getAbsoluteContextURL();
String url = rootURL + "/roller-ui/menu.rol";
ResourceBundle resources = ResourceBundle.getBundle(
"ApplicationResources",
website.getLocaleInstance());
StringBuffer sb = new StringBuffer();
sb.append(MessageFormat.format(
resources.getString("inviteMember.notificationSubject"),
new Object[] {
website.getName(),
website.getHandle()})
);
subject = sb.toString();
sb = new StringBuffer();
sb.append(MessageFormat.format(
resources.getString("inviteMember.notificationContent"),
new Object[] {
website.getName(),
website.getHandle(),
user.getUserName(),
url
}));
content = sb.toString();
MailUtil.sendTextMessage(
from, to, cc, bcc, subject, content);
} catch (MessagingException e) {
throw new WebloggerException("ERROR: Notification email(s) not sent, "
+ "due to Roller configuration or mail server problem.", e);
}
}