org.apache.cocoon.mail
Interface MailSender

All Known Implementing Classes:
MailMessageSender

public interface MailSender

A helper component used by the Sendmail action and the sendmail.xsl logicsheet for sending email messages.

Please note that this component is not (and can not) be ThreadSafe, so you need to lookup new instance in each processing thread.

Since:
2.1.5
Version:
$Id: MailSender.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Field Summary
static String ROLE
           
 
Method Summary
 void addAttachment(Object attachment)
          Add an attachement to the message to be send.
 void addAttachment(Object attachment, String type, String name)
          Add an attachement to the message to be send.
 void addAttachmentURL(String url)
          Add an attachement to the message to be send.
 void addAttachmentURL(String url, String type, String name)
          Add an attachement to the message to be send.
 Exception getException()
          Accesses any Exception caught by sendIt(SourceResolver).
 void send()
          Assemble the message from the defined fields and send it.
 void send(SourceResolver resolver)
          Deprecated. Since 2.1.5. Use send() which doesn't require passing the source resolver
 boolean sendIt()
          Invokes the send() method but catches any exception thrown.
 boolean sendIt(SourceResolver resolver)
          Deprecated. Since 2.1.5. Use sendIt() which doesn't require passing the source resolver
 void setBcc(String bcc)
          Sets the address(es), which should receive a black carbon copy of the message.
 void setBody(Object body)
          Sets the body content of the email message.
 void setBody(Object body, String type)
          Sets the body content of the email message.
 void setBody(String body)
          Deprecated. Since 2.1.10. Use setBody(Object)
 void setBodyFromSrc(String src)
          Deprecated. Since 2.1.10. Use setBodyURL(String)
 void setBodyFromSrcMimeType(String srcMimeType)
          Deprecated. Since 2.1.10. Use setBodyURL(String, String)
 void setBodyURL(String url)
          Sets the body content of the email message.
 void setBodyURL(String url, String type)
          Sets the body content of the email message.
 void setCc(String cc)
          Sets the address(es), which should receive a carbon copy of the message.
 void setCharset(String charset)
          Deprecated. Since 2.1.10. Use setBody(Object, String)
 void setFrom(String from)
          Set the from address of the message.
 void setReplyTo(String replyTo)
          Sets the reply-to address(es) for the message.
 void setSmtpHost(String hostname)
          Set SMTP hostname to use for mail sending.
 void setSmtpHost(String hostname, String username, String password)
          Set SMTP hostname, username, and password to use for mail sending.
 void setSubject(String subject)
          Sets the subject line of the message.
 void setTo(String to)
          Sets the destination address(es) for the message.
 

Field Detail

ROLE

static final String ROLE
Method Detail

setSmtpHost

void setSmtpHost(String hostname)
Set SMTP hostname to use for mail sending.


setSmtpHost

void setSmtpHost(String hostname,
                 String username,
                 String password)
Set SMTP hostname, username, and password to use for mail sending.


setFrom

void setFrom(String from)
Set the from address of the message.

Parameters:
from - The address the message appears to be from.

setTo

void setTo(String to)
Sets the destination address(es) for the message. The address is in the format, that InternetAddress.parse(String) can handle (one or more email addresses separated by a commas).

Parameters:
to - the destination address(es)
See Also:
InternetAddress.parse(String)

setReplyTo

void setReplyTo(String replyTo)
Sets the reply-to address(es) for the message. The address is in the format, that InternetAddress.parse(String) can handle (one or more email addresses separated by a commas).

Parameters:
replyTo - the address(es) that replies should be sent to
See Also:
InternetAddress.parse(String)

setCc

void setCc(String cc)
Sets the address(es), which should receive a carbon copy of the message. The address is in the format, that InternetAddress.parse(String) can handle (one or more email addresses separated by a commas).

Parameters:
cc - the address(es), which should receive a carbon copy.
See Also:
InternetAddress.parse(String)

setBcc

void setBcc(String bcc)
Sets the address(es), which should receive a black carbon copy of the message. The address is in the format, that InternetAddress.parse(String) can handle (one or more email addresses separated by a commas).

Parameters:
bcc - the address(es), which should receive a black carbon copy.
See Also:
InternetAddress.parse(String)

setSubject

void setSubject(String subject)
Sets the subject line of the message.

Parameters:
subject - the subject line of the message

setCharset

void setCharset(String charset)
Deprecated. Since 2.1.10. Use setBody(Object, String)

Sets the character set for encoding the message. This has effect only on text set via setBody(String).

Parameters:
charset - the character set to be used for encoding the message

setBody

void setBody(String body)
Deprecated. Since 2.1.10. Use setBody(Object)

Sets the body text of the email message. If both a text body and a body read from a source are set, only the latter will be used.

Parameters:
body - The body text of the email message

setBodyFromSrc

void setBodyFromSrc(String src)
Deprecated. Since 2.1.10. Use setBodyURL(String)

Sets the body source URL of the email message. If both a text body and a body read from a source are set, only the latter will be used.

Parameters:
src - The body source URL of the email message

setBodyFromSrcMimeType

void setBodyFromSrcMimeType(String srcMimeType)
Deprecated. Since 2.1.10. Use setBodyURL(String, String)

Sets the optional body source Mime Type of the email message.

Parameters:
srcMimeType - The optional body source Mime Type of the email message

setBody

void setBody(Object body)
Sets the body content of the email message.

The body can be any of: Source, Part, InputStream, byte[], String, or a subclass.

Parameters:
body - The body text of the email message

setBody

void setBody(Object body,
             String type)
Sets the body content of the email message.

The body can be any of: Source, Part, InputStream, byte[], String, or a subclass.

Parameters:
body - The body text of the email message
type - mime type (optional)

setBodyURL

void setBodyURL(String url)
Sets the body content of the email message.

Parameters:
url - URL to use as message body
See Also:
Source

setBodyURL

void setBodyURL(String url,
                String type)
Sets the body content of the email message.

Parameters:
url - URL to use as message body
type - mime type (optional)
See Also:
Source

addAttachment

void addAttachment(Object attachment)
Add an attachement to the message to be send.

The attachment can be any of: Source, Part, InputStream, byte[], String, or a subclass.

Parameters:
attachment - to be send with the message

addAttachment

void addAttachment(Object attachment,
                   String type,
                   String name)
Add an attachement to the message to be send.

The attachment can be any of: Source, Part, InputStream, byte[], String, or a subclass.

Parameters:
attachment - to be send with the message
type - mime type (optional)
name - attachment name (optional)

addAttachmentURL

void addAttachmentURL(String url)
Add an attachement to the message to be send.

Parameters:
url - URL to attach to the message
See Also:
Source

addAttachmentURL

void addAttachmentURL(String url,
                      String type,
                      String name)
Add an attachement to the message to be send.

Parameters:
url - URL to attach to the message
type - mime type (optional)
name - attachment name (optional)
See Also:
Source

send

void send()
          throws AddressException,
                 MessagingException
Assemble the message from the defined fields and send it. The source resolver is obtained from the hosting component container.

Throws:
AddressException - when problems with email addresses are found
MessagingException - when message could not be send.

send

void send(SourceResolver resolver)
          throws AddressException,
                 MessagingException
Deprecated. Since 2.1.5. Use send() which doesn't require passing the source resolver

Assemble the message from the defined fields and send it.

Throws:
AddressException - when problems with email addresses are found
MessagingException - when message could not be send.

sendIt

boolean sendIt()
Invokes the send() method but catches any exception thrown. This method is intended to be used from the sendmail logicsheet. The source resolver is obtained from the hosting component container.

Returns:
true when successful

sendIt

boolean sendIt(SourceResolver resolver)
Deprecated. Since 2.1.5. Use sendIt() which doesn't require passing the source resolver

Invokes the send(SourceResolver) method but catches any exception thrown. This method is intended to be used from the sendmail logicsheet.

Returns:
true when successful

getException

Exception getException()
Accesses any Exception caught by sendIt(SourceResolver).

Returns:
AddressException or MessagingException


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.