Example usage for org.springframework.mail MailAuthenticationException getMessage

List of usage examples for org.springframework.mail MailAuthenticationException getMessage

Introduction

In this page you can find the example usage for org.springframework.mail MailAuthenticationException getMessage.

Prototype

@Override
@Nullable
public String getMessage() 

Source Link

Document

Return the detail message, including the message from the nested exception if there is one.

Usage

From source file:org.osaf.cosmo.scheduler.EmailNotifier.java

protected void sendEmail(final String[] emailAddresses, final String subject, final String text,
        final boolean isHtml) {

    if (log.isDebugEnabled()) {
        log.debug("sending email to:");
        for (String s : emailAddresses)
            log.debug(s);//from  www .ja  va  2  s.  c om
        log.debug(subject);
        log.debug(text);
    }

    for (final String address : emailAddresses) {
        try {
            mailSender.send(new MimeMessagePreparator() {
                public void prepare(MimeMessage mimeMessage) throws MessagingException {

                    String fromAddr = properties.get(PROPERTY_FROM_ADDRESS);
                    String fromHandle = properties.get(PROPERTY_FROM_HANDLE);

                    MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
                    message.setFrom("\"" + fromHandle + "\" <" + fromAddr + ">");
                    message.setTo(address.trim());
                    message.setSubject(subject);
                    message.setText(text, isHtml);
                }
            });
        } catch (MailAuthenticationException e) {
            log.error(e.getMessage());
        } catch (MailException e) {
            log.info("failed to send email to " + address + ": " + e.getMessage());
        }
    }
}