1 /* 2 * Copyright 2002-2012 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.springframework.mail.javamail; 18 19 import javax.mail.internet.MimeMessage; 20 21 /** 22 * Callback interface for the preparation of JavaMail MIME messages. 23 * 24 * <p>The corresponding {@code send} methods of {@link JavaMailSender} 25 * will take care of the actual creation of a {@link MimeMessage} instance, 26 * and of proper exception conversion. 27 * 28 * <p>It is often convenient to use a {@link MimeMessageHelper} for populating 29 * the passed-in MimeMessage, in particular when working with attachments or 30 * special character encodings. 31 * See {@link MimeMessageHelper MimeMessageHelper's javadoc} for an example. 32 * 33 * @author Juergen Hoeller 34 * @since 07.10.2003 35 * @see JavaMailSender#send(MimeMessagePreparator) 36 * @see JavaMailSender#send(MimeMessagePreparator[]) 37 * @see MimeMessageHelper 38 */ 39 public interface MimeMessagePreparator { 40 41 /** 42 * Prepare the given new MimeMessage instance. 43 * @param mimeMessage the message to prepare 44 * @throws javax.mail.MessagingException passing any exceptions thrown by MimeMessage 45 * methods through for automatic conversion to the MailException hierarchy 46 * @throws java.io.IOException passing any exceptions thrown by MimeMessage methods 47 * through for automatic conversion to the MailException hierarchy 48 * @throws Exception if mail preparation failed, for example when a 49 * Velocity template cannot be rendered for the mail text 50 */ 51 void prepare(MimeMessage mimeMessage) throws Exception; 52 53 }