001/* 002 * Copyright 2002-2014 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.mail; 018 019/** 020 * This interface defines a strategy for sending simple mails. Can be 021 * implemented for a variety of mailing systems due to the simple requirements. 022 * For richer functionality like MIME messages, consider JavaMailSender. 023 * 024 * <p>Allows for easy testing of clients, as it does not depend on JavaMail's 025 * infrastructure classes: no mocking of JavaMail Session or Transport necessary. 026 * 027 * @author Dmitriy Kopylenko 028 * @author Juergen Hoeller 029 * @since 10.09.2003 030 * @see org.springframework.mail.javamail.JavaMailSender 031 */ 032public interface MailSender { 033 034 /** 035 * Send the given simple mail message. 036 * @param simpleMessage the message to send 037 * @throws MailParseException in case of failure when parsing the message 038 * @throws MailAuthenticationException in case of authentication failure 039 * @throws MailSendException in case of failure when sending the message 040 */ 041 void send(SimpleMailMessage simpleMessage) throws MailException; 042 043 /** 044 * Send the given array of simple mail messages in batch. 045 * @param simpleMessages the messages to send 046 * @throws MailParseException in case of failure when parsing a message 047 * @throws MailAuthenticationException in case of authentication failure 048 * @throws MailSendException in case of failure when sending a message 049 */ 050 void send(SimpleMailMessage... simpleMessages) throws MailException; 051 052}