org.springframework.mail.javamail
Interface JavaMailSender

All Known Implementing Classes:
JavaMailSenderImpl

public interface JavaMailSender
extends MailSender

Extended MailSender interface for JavaMail, supporting MIME messages both as direct arguments and via preparation callbacks.

Not as easy to test as a plain MailSender, but still rather easy compared to full JavaMail code: Just let createMimeMessage return a plain Session created with a Session.getInstance (empty properties) call, and check the given messages in your mock implementations of the various send methods.

Author:
Juergen Hoeller
See Also: JavaMailSenderImpl

Method Summary
 MimeMessagecreateMimeMessage()
          Create a new JavaMail MimeMessage for the underlying JavaMail Session of this sender.
 voidsend(MimeMessage mimeMessage)
          Send the given JavaMail MIME message.
 voidsend(MimeMessage[] mimeMessages)
          Send the given array of JavaMail MIME messages in batch.
 voidsend(MimeMessagePreparator mimeMessagePreparator)
          Send the JavaMail MIME message prepared by the given MimeMessagePreparator.
 voidsend(MimeMessagePreparator[] mimeMessagePreparators)
          Send the JavaMail MIME messages prepared by the given MimeMessagePreparators.

Methods inherited from interface org.springframework.mail.MailSender
send

Method Detail

createMimeMessage

public MimeMessage createMimeMessage()
Create a new JavaMail MimeMessage for the underlying JavaMail Session of this sender. Needs to be called to create MimeMessage instances that can be prepared by the client and passed to send(MimeMessage).
Returns: the new MimeMessage instance
See Also:
send(MimeMessage), send(MimeMessage[])

send

public void send(MimeMessage mimeMessage)
throws org.springframework.mail.MailException
Send the given JavaMail MIME message. The message needs to have been created with createMimeMessage.
Parameters:
mimeMessage - message to send
Throws:
MailException - in case of message, authentication, or send errors
See Also:
createMimeMessage()

send

public void send(MimeMessage[] mimeMessages)
throws org.springframework.mail.MailException
Send the given array of JavaMail MIME messages in batch. The messages need to have been created with createMimeMessage.
Parameters:
mimeMessages - messages to send
Throws:
MailException - in case of message, authentication, or send errors
See Also:
createMimeMessage()

send

public void send(MimeMessagePreparator mimeMessagePreparator)
throws org.springframework.mail.MailException
Send the JavaMail MIME message prepared by the given MimeMessagePreparator. Alternative way to prepare MimeMessage instances, instead of createMimeMessage and send(MimeMessage) calls. Takes care of proper exception conversion.
Parameters:
mimeMessagePreparator - the preparator to use
Throws:
MailException - in case of message, authentication, or send errors

send

public void send(MimeMessagePreparator[] mimeMessagePreparators)
throws org.springframework.mail.MailException
Send the JavaMail MIME messages prepared by the given MimeMessagePreparators. Alternative way to prepare MimeMessage instances, instead of createMimeMessage and send(MimeMessage[]) calls. Takes care of proper exception conversion.
Parameters:
mimeMessagePreparators - the preparator to use
Throws:
MailException - in case of message, authentication, or send errors