Example usage for org.springframework.mail MailException MailException

List of usage examples for org.springframework.mail MailException MailException

Introduction

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

Prototype

public MailException(@Nullable String msg, @Nullable Throwable cause) 

Source Link

Document

Constructor for MailException.

Usage

From source file:dk.teachus.backend.bean.impl.TestSpringMailBean.java

private MailBean createMailBean() throws NoSuchFieldException, IllegalAccessException {
    // Replace mailsender with a dummy
    JavaMailSender mailSender = new JavaMailSender() {
        private JavaMailSender wrappedSender = new JavaMailSenderImpl();

        public MimeMessage createMimeMessage() {
            return wrappedSender.createMimeMessage();
        }/*  www  .j  a  v a2s.  com*/

        public MimeMessage createMimeMessage(InputStream arg0) throws MailException {
            return wrappedSender.createMimeMessage(arg0);
        }

        public void send(MimeMessage arg0) throws MailException {
        }

        public void send(MimeMessage[] arg0) throws MailException {
        }

        public void send(MimeMessagePreparator arg0) throws MailException {
            try {
                arg0.prepare(createMimeMessage());
            } catch (Exception e) {
                throw new MailException("", e) {
                    private static final long serialVersionUID = 1L;
                };
            }
        }

        public void send(MimeMessagePreparator[] arg0) throws MailException {
        }

        public void send(SimpleMailMessage arg0) throws MailException {
        }

        public void send(SimpleMailMessage[] arg0) throws MailException {
        }
    };

    return new SpringMailBean(mailSender);
}