@Override protected void onEvent(EventTemplate event) { if (event instanceof MessageEvent) { MessageEvent mail = (MessageEvent) event; try { send(mail.getFrom(), mail.getTo(), null, mail.getText()); } catch (MessagingException ex) { this.notifyCriticalError( "Error while sending email to " + mail.getTo() + ": " + ex.getMessage()); } } }
@Override protected void onCommand(Command c) throws IOException, UnableToExecuteException { String from = c.getProperty("from"); if (from == null) { from = "*****@*****.**"; } String to = c.getProperty("to"); String subject = c.getProperty("subject"); final String text = c.getProperty("message"); try { send(from, to, subject, text); } catch (MessagingException ex) { this.notifyCriticalError( "Error while sending email '" + subject + "' to '" + to + "' " + ex.getMessage()); } }