List of usage examples for org.springframework.mail MailException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:net.malariagen.alfresco.action.CustomMailAction.java
/** * Send a test message//from w w w. j ava2 s.co m * * @return true, message sent * @throws AlfrescoRuntimeException */ public boolean sendTestMessage() { if (testMessageTo == null || testMessageTo.length() == 0) { throw new AlfrescoRuntimeException("email.outbound.err.test.no.to"); } if (testMessageSubject == null || testMessageSubject.length() == 0) { throw new AlfrescoRuntimeException("email.outbound.err.test.no.subject"); } if (testMessageText == null || testMessageText.length() == 0) { throw new AlfrescoRuntimeException("email.outbound.err.test.no.text"); } Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put(PARAM_TO, testMessageTo); params.put(PARAM_SUBJECT, testMessageSubject); params.put(PARAM_TEXT, testMessageText); Action ruleAction = serviceRegistry.getActionService().createAction(NAME, params); MimeMessageHelper message = prepareEmail(ruleAction, null, new Pair<String, Locale>(testMessageTo, getLocaleForUser(testMessageTo)), getFrom(ruleAction)); try { mailService.send(message.getMimeMessage()); onSend(); } catch (MailException me) { onFail(); StringBuffer txt = new StringBuffer(); txt.append(me.getClass().getName() + ", " + me.getMessage()); Throwable cause = me.getCause(); while (cause != null) { txt.append(", "); txt.append(cause.getClass().getName() + ", " + cause.getMessage()); cause = cause.getCause(); } Object[] args = { testMessageTo, txt.toString() }; throw new AlfrescoRuntimeException("email.outbound.err.send.failed", args, me); } return true; }