Package org.springframework.mail

Examples of org.springframework.mail.MailSendException


        try {
            Store store = getSession().getStore(protocol);
            store.connect(getHost(), getPort(), getUsername(), getPassword());
            return store.getFolder(folderName);
        } catch (MessagingException e) {
            throw new MailSendException("Mail server connection failed", e);
        }
    }
View Full Code Here


        try {
            Store store = getSession().getStore(protocol);
            store.connect(getHost(), getPort(), getUsername(), getPassword());
            return store.getFolder(folderName);
        } catch (MessagingException e) {
            throw new MailSendException("Mail server connection failed", e);
        }
    }
View Full Code Here

      // Effectively, all messages failed...
      for (int i = 0; i < mimeMessages.length; i++) {
        Object original = (originalMessages != null ? originalMessages[i] : mimeMessages[i]);
        failedMessages.put(original, ex);
      }
      throw new MailSendException("Mail server connection failed", ex, failedMessages);
    }

    try {
      for (int i = 0; i < mimeMessages.length; i++) {
        MimeMessage mimeMessage = mimeMessages[i];
        try {
          if (mimeMessage.getSentDate() == null) {
            mimeMessage.setSentDate(new Date());
          }
          String messageId = mimeMessage.getMessageID();
          mimeMessage.saveChanges();
          if (messageId != null) {
            // Preserve explicitly specified message id...
            mimeMessage.setHeader(HEADER_MESSAGE_ID, messageId);
          }
          transport.sendMessage(mimeMessage, mimeMessage.getAllRecipients());
        }
        catch (MessagingException ex) {
          Object original = (originalMessages != null ? originalMessages[i] : mimeMessage);
          failedMessages.put(original, ex);
        }
      }
    }
    finally {
      try {
        transport.close();
      }
      catch (MessagingException ex) {
        if (!failedMessages.isEmpty()) {
          throw new MailSendException("Failed to close server connection after message failures", ex,
              failedMessages);
        }
        else {
          throw new MailSendException("Failed to close server connection after message sending", ex);
        }
      }
    }

    if (!failedMessages.isEmpty()) {
      throw new MailSendException(failedMessages);
    }
  }
View Full Code Here

        }
      }
    }

    log.error("Email delivery for '" + context.getName() + "' FAILED");
    throw new MailSendException("Failed email delivery attempt: " + context.getName());
  }
View Full Code Here

        }
      }
    }

    log.error("Email delivery for '" + context.getName() + "' FAILED");
    throw new MailSendException("Failed email delivery attempt: " + context.getName());
  }
View Full Code Here

    }
    catch (AuthenticationFailedException ex) {
      throw new MailAuthenticationException(ex);
    }
    catch (MessagingException ex) {
      throw new MailSendException("Mail server connection failed", ex);
    }
    if (!failedMessages.isEmpty()) {
      throw new MailSendException(failedMessages);
    }
  }
View Full Code Here

        failedMessages.put(simpleMessage, ex);
      }
    }

    if (!failedMessages.isEmpty()) {
      throw new MailSendException(failedMessages);
    }
  }
View Full Code Here

    }
    catch (AuthenticationFailedException ex) {
      throw new MailAuthenticationException(ex);
    }
    catch (MessagingException ex) {
      throw new MailSendException("Mail server connection failed", ex);
    }
    if (!failedMessages.isEmpty()) {
      throw new MailSendException(failedMessages);
    }
  }
View Full Code Here

    assertTrue(rr.getDepth(new Exception()) == 0);
  }
 
  public void testNotFound() {
    RollbackRuleAttribute rr = new RollbackRuleAttribute("javax.servlet.ServletException");
    assertTrue(rr.getDepth(new MailSendException("")) == -1);
  }
View Full Code Here

  }
 
  public void testAncestry() {
    RollbackRuleAttribute rr = new RollbackRuleAttribute("java.lang.Exception");
    // Exception -> Runtime -> NestedRuntime -> MailException -> MailSendException
    assertTrue(rr.getDepth(new MailSendException("")) == 4);
  }
View Full Code Here

TOP

Related Classes of org.springframework.mail.MailSendException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.