org.springframework.integration.mail
Class MailSendingMessageHandler

java.lang.Object
  extended by org.springframework.integration.mail.MailSendingMessageHandler
All Implemented Interfaces:
MessageHandler

public class MailSendingMessageHandler
extends java.lang.Object
implements MessageHandler

A MessageHandler implementation for sending mail.

If the Message is an instance of MailMessage, it will be passed as-is. If the Message payload is a byte array, it will be passed as an attachment, and in that case, the MailHeaders.ATTACHMENT_FILENAME header is required. For any other payload type, a SimpleMailMessage will be created with the payload's toString() value as the Mail text.

Author:
Marius Bogoevici, Mark Fisher
See Also:
MailHeaders

Constructor Summary
MailSendingMessageHandler(org.springframework.mail.javamail.JavaMailSender mailSender)
          Create a MailSendingMessageConsumer.
 
Method Summary
 void handleMessage(Message<?> message)
          Handles the message if possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailSendingMessageHandler

public MailSendingMessageHandler(org.springframework.mail.javamail.JavaMailSender mailSender)
Create a MailSendingMessageConsumer.

Parameters:
mailSender - the JavaMailSender instance to which this adapter will delegate.
Method Detail

handleMessage

public final void handleMessage(Message<?> message)
Description copied from interface: MessageHandler
Handles the message if possible. If the handler cannot deal with the message this will result in a MessageRejectedException e.g. in case of a Selective Consumer. When a consumer tries to handle a message, but fails to do so, a MessageHandlingException is thrown. In the last case it is recommended to treat the message as tainted and go into an error scenario.

When the handling results in a message being sent failure to send that message will result in a MessageDeliveryException.

Specified by:
handleMessage in interface MessageHandler
Parameters:
message - the message to be handled