This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


com.sun.mail.smtp
class SMTPMessage

javax.mail.Message extended by javax.mail.internet.MimeMessage extended by com.sun.mail.smtp.SMTPMessage
All Implemented Interfaces:
Part, MimePart

public class SMTPMessage
extends MimeMessage

This class is a specialization of the MimeMessage class that allows you to specify various SMTP options and parameters that will be used when this message is sent over SMTP. Simply use this class instead of MimeMessage and set SMTP options using the methods on this class.

See the com.sun.mail.smtp package documentation for further information on the SMTP protocol provider.


Nested Class Summary
 
Nested classes/interfaces inherited from class javax.mail.internet.MimeMessage
MimeMessage.RecipientType
 
Nested classes/interfaces inherited from class javax.mail.Message
Message.RecipientType
   
Field Summary
static int NOTIFY_DELAY
          Notify of delivery delay
static int NOTIFY_FAILURE
          Notify of delivery failure
static int NOTIFY_NEVER
          Never notify of delivery status
static int NOTIFY_SUCCESS
          Notify of delivery success
static int RETURN_FULL
          Return full message with delivery status notification
static int RETURN_HDRS
          Return only message headers with delivery status notification
 
Fields inherited from class javax.mail.internet.MimeMessage
content, contentStream, dh, flags, headers, modified, saved
 
Fields inherited from class javax.mail.Message
expunged, folder, msgnum, session
 
Constructor Summary

          Constructs a new SMTPMessage with content initialized from the source MimeMessage.

          Default constructor.

          Constructs an SMTPMessage by reading and parsing the data from the specified MIME InputStream.
 
Method Summary
 boolean

          Is use of the 8BITMIME extension is allowed?
 String

          Return the envelope From address.
 String

          Gets the extension string to use with the MAIL command.
 int

          Get notification options.
 int

          Return return option.
 boolean

          Send message if some addresses are invalid?
 String

          Gets the submitter to be used for the RFC 2554 AUTH= value in the MAIL FROM command.
 void
setAllow8bitMIME(boolean allow)

          If set to true, and the server supports the 8BITMIME extension, text parts of this message that use the "quoted-printable" or "base64" encodings are converted to use "8bit" encoding if they follow the RFC 2045 rules for 8bit text.
 void

          Set the From address to appear in the SMTP envelope.
 void

          Set the extension string to use with the MAIL command.
 void
setNotifyOptions(int options)

          Set notification options to be used if the server supports Delivery Status Notification (RFC 1891).
 void
setReturnOption(int option)

          Set return option to be used if server supports Delivery Status Notification (RFC 1891).
 void
setSendPartial(boolean partial)

          If set to true, and this message has some valid and some invalid addresses, send the message anyway, reporting the partial failure with a SendFailedException.
 void
setSubmitter(String submitter)

          Sets the submitter to be used for the RFC 2554 AUTH= value in the MAIL FROM command.
 
Methods inherited from class javax.mail.internet.MimeMessage
addFrom, addHeader, addHeaderLine, addRecipients, addRecipients, createInternetHeaders, createMimeMessage, getAllHeaderLines, getAllHeaders, getAllRecipients, getContent, getContentID, getContentLanguage, getContentMD5, getContentStream, getContentType, getDataHandler, getDescription, getDisposition, getEncoding, getFileName, getFlags, getFrom, getHeader, getHeader, getInputStream, getLineCount, getMatchingHeaderLines, getMatchingHeaders, getMessageID, getNonMatchingHeaderLines, getNonMatchingHeaders, getRawInputStream, getReceivedDate, getRecipients, getReplyTo, getSender, getSentDate, getSize, getSubject, isMimeType, isSet, parse, removeHeader, reply, saveChanges, setContent, setContent, setContentID, setContentLanguage, setContentMD5, setDataHandler, setDescription, setDescription, setDisposition, setFileName, setFlags, setFrom, setFrom, setHeader, setRecipients, setRecipients, setReplyTo, setSender, setSentDate, setSubject, setSubject, setText, setText, setText, updateHeaders, updateMessageID, writeTo, writeTo
 
Methods inherited from class javax.mail.Message
addFrom, addRecipient, addRecipients, getAllRecipients, getFlags, getFolder, getFrom, getMessageNumber, getReceivedDate, getRecipients, getReplyTo, getSentDate, getSubject, isExpunged, isSet, match, reply, saveChanges, send, setExpunged, setFlag, setFlags, setFrom, setFrom, setMessageNumber, setRecipient, setRecipients, setReplyTo, setSentDate, setSubject
 

Field Detail

NOTIFY_DELAY

public static final int NOTIFY_DELAY
Notify of delivery delay

NOTIFY_FAILURE

public static final int NOTIFY_FAILURE
Notify of delivery failure

NOTIFY_NEVER

public static final int NOTIFY_NEVER
Never notify of delivery status

NOTIFY_SUCCESS

public static final int NOTIFY_SUCCESS
Notify of delivery success

RETURN_FULL

public static final int RETURN_FULL
Return full message with delivery status notification

RETURN_HDRS

public static final int RETURN_HDRS
Return only message headers with delivery status notification
Constructor Detail

SMTPMessage

public SMTPMessage(MimeMessage source)
            throws MessagingException
Constructs a new SMTPMessage with content initialized from the source MimeMessage. The new message is independent of the original.

Note: The current implementation is rather inefficient, copying the data more times than strictly necessary.

Parameters:
source - the message to copy content from
Throws:
MessagingException

SMTPMessage

public SMTPMessage(Session session)
Default constructor. An empty message object is created. The headers field is set to an empty InternetHeaders object. The flags field is set to an empty Flags object. The modified flag is set to true.

Parameters:
session

SMTPMessage

public SMTPMessage(Session session,
                   InputStream is)
            throws MessagingException
Constructs an SMTPMessage by reading and parsing the data from the specified MIME InputStream. The InputStream will be left positioned at the end of the data for the message. Note that the input stream parse is done within this constructor itself.

Parameters:
session - Session object for this message
is - the message input stream
Throws:
MessagingException
Method Detail

getAllow8bitMIME

public boolean getAllow8bitMIME()
Is use of the 8BITMIME extension is allowed?

Returns:
allow 8-bit flag

getEnvelopeFrom

public String getEnvelopeFrom()
Return the envelope From address.

Returns:
the envelope From address, or null if not set

getMailExtension

public String getMailExtension()
Gets the extension string to use with the MAIL command.

Returns:
the extension string

getNotifyOptions

public int getNotifyOptions()
Get notification options. Returns zero if no options set.

Returns:
notification options

getReturnOption

public int getReturnOption()
Return return option. Returns zero if no option set.

Returns:
return option

getSendPartial

public boolean getSendPartial()
Send message if some addresses are invalid?

Returns:
send partial flag

getSubmitter

public String getSubmitter()
Gets the submitter to be used for the RFC 2554 AUTH= value in the MAIL FROM command.

Returns:
the name of the submitter.

setAllow8bitMIME

public void setAllow8bitMIME(boolean allow)
If set to true, and the server supports the 8BITMIME extension, text parts of this message that use the "quoted-printable" or "base64" encodings are converted to use "8bit" encoding if they follow the RFC 2045 rules for 8bit text.

If true, overrides the mail.smtp.allow8bitmime property.

Parameters:
allow - allow 8-bit flag

setEnvelopeFrom

public void setEnvelopeFrom(String from)
Set the From address to appear in the SMTP envelope. Note that this is different than the From address that appears in the message itself. The envelope From address is typically used when reporting errors. See RFC 821 for details.

If set, overrides the mail.smtp.from property.

Parameters:
from - the envelope From address

setMailExtension

public void setMailExtension(String extension)
Set the extension string to use with the MAIL command. The extension string can be used to specify standard SMTP service extensions as well as vendor-specific extensions. Typically the application should use the {@link com.sun.mail.smtp.SMTPTransport SMTPTransport} method {@link com.sun.mail.smtp.SMTPTransport#supportsExtension supportsExtension} to verify that the server supports the desired service extension. See RFC 1869 and other RFCs that define specific extensions.

For example:

 if (smtpTransport.supportsExtension("DELIVERBY"))
    smtpMsg.setMailExtension("BY=60;R");
 

Parameters:
extension

setNotifyOptions

public void setNotifyOptions(int options)
Set notification options to be used if the server supports Delivery Status Notification (RFC 1891). Either NOTIFY_NEVER or some combination of NOTIFY_SUCCESS, NOTIFY_FAILURE, and NOTIFY_DELAY.

If set, overrides the mail.smtp.dsn.notify property.

Parameters:
options - notification options

setReturnOption

public void setReturnOption(int option)
Set return option to be used if server supports Delivery Status Notification (RFC 1891). Either RETURN_FULL or RETURN_HDRS.

If set, overrides the mail.smtp.dsn.ret property.

Parameters:
option - return option

setSendPartial

public void setSendPartial(boolean partial)
If set to true, and this message has some valid and some invalid addresses, send the message anyway, reporting the partial failure with a SendFailedException. If set to false (the default), the message is not sent to any of the recipients if there is an invalid recipient address.

If true, overrides the mail.smtp.sendpartial property.

Parameters:
partial - send partial flag

setSubmitter

public void setSubmitter(String submitter)
Sets the submitter to be used for the RFC 2554 AUTH= value in the MAIL FROM command. Normally only used by a server that's relaying a message. Clients will typically not set a submitter. See RFC 2554 for details.

Parameters:
submitter - the name of the submitter


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention. The official Sun™ documentation can be found here at http://java.sun.com/products/javamail/javadocs/index.html.