java.lang.Object
jakarta.mail.Message
jakarta.mail.internet.MimeMessage
org.eclipse.angus.mail.smtp.SMTPMessage
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 org.eclipse.angus.mail.smtp package documentation for further information on the SMTP protocol provider.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class jakarta.mail.internet.MimeMessage
MimeMessage.RecipientType
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Notify of delivery delaystatic final int
Notify of delivery failurestatic final int
Never notify of delivery statusstatic final int
Notify of delivery successstatic final int
Return full message with delivery status notificationstatic final int
Return only message headers with delivery status notificationFields inherited from class jakarta.mail.internet.MimeMessage
cachedContent, content, contentStream, dh, flags, headers, modified, saved
Fields inherited from interface jakarta.mail.Part
ATTACHMENT, INLINE
-
Constructor Summary
ConstructorDescriptionSMTPMessage
(MimeMessage source) Constructs a new SMTPMessage with content initialized from thesource
MimeMessage.SMTPMessage
(Session session) Default constructor.SMTPMessage
(Session session, InputStream is) Constructs an SMTPMessage by reading and parsing the data from the specified MIME InputStream. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Is use of the 8BITMIME extension is allowed?Return the envelope From address.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?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
setEnvelopeFrom
(String from) Set the From address to appear in the SMTP envelope.void
setMailExtension
(String extension) 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 jakarta.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, reply, saveChanges, setContent, setContent, setContentID, setContentLanguage, setContentMD5, setDataHandler, setDescription, setDescription, setDisposition, setFileName, setFlags, setFrom, setFrom, setFrom, setHeader, setRecipients, setRecipients, setReplyTo, setSender, setSentDate, setSubject, setSubject, setText, setText, setText, updateHeaders, updateMessageID, writeTo, writeTo
Methods inherited from class jakarta.mail.Message
addRecipient, getFolder, getMessageNumber, getSession, isExpunged, match, setExpunged, setFlag, setMessageNumber, setRecipient
-
Field Details
-
NOTIFY_NEVER
public static final int NOTIFY_NEVERNever notify of delivery status- See Also:
-
NOTIFY_SUCCESS
public static final int NOTIFY_SUCCESSNotify of delivery success- See Also:
-
NOTIFY_FAILURE
public static final int NOTIFY_FAILURENotify of delivery failure- See Also:
-
NOTIFY_DELAY
public static final int NOTIFY_DELAYNotify of delivery delay- See Also:
-
RETURN_FULL
public static final int RETURN_FULLReturn full message with delivery status notification- See Also:
-
RETURN_HDRS
public static final int RETURN_HDRSReturn only message headers with delivery status notification- See Also:
-
-
Constructor Details
-
SMTPMessage
Default constructor. An empty message object is created. Theheaders
field is set to an empty InternetHeaders object. Theflags
field is set to an empty Flags object. Themodified
flag is set to true.- Parameters:
session
- the Session
-
SMTPMessage
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 messageis
- the message input stream- Throws:
MessagingException
- for failures
-
SMTPMessage
Constructs a new SMTPMessage with content initialized from thesource
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
- for failures
-
-
Method Details
-
setEnvelopeFrom
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
-
getEnvelopeFrom
Return the envelope From address.- Returns:
- the envelope From address, or null if not set
-
setNotifyOptions
public void setNotifyOptions(int options) Set notification options to be used if the server supports Delivery Status Notification (RFC 1891). EitherNOTIFY_NEVER
or some combination ofNOTIFY_SUCCESS
,NOTIFY_FAILURE
, andNOTIFY_DELAY
.If set, overrides the
mail.smtp.dsn.notify
property.- Parameters:
options
- notification options
-
getNotifyOptions
public int getNotifyOptions()Get notification options. Returns zero if no options set.- Returns:
- notification options
-
setReturnOption
public void setReturnOption(int option) Set return option to be used if server supports Delivery Status Notification (RFC 1891). EitherRETURN_FULL
orRETURN_HDRS
.If set, overrides the
mail.smtp.dsn.ret
property.- Parameters:
option
- return option
-
getReturnOption
public int getReturnOption()Return return option. Returns zero if no option set.- Returns:
- return option
-
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
-
getAllow8bitMIME
public boolean getAllow8bitMIME()Is use of the 8BITMIME extension is allowed?- Returns:
- allow 8-bit flag
-
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
-
getSendPartial
public boolean getSendPartial()Send message if some addresses are invalid?- Returns:
- send partial flag
-
getSubmitter
Gets the submitter to be used for the RFC 2554 AUTH= value in the MAIL FROM command.- Returns:
- the name of the submitter.
-
setSubmitter
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
-
getMailExtension
Gets the extension string to use with the MAIL command.- Returns:
- the extension string
- Since:
- JavaMail 1.3.2
-
setMailExtension
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 theSMTPTransport
methodsupportsExtension
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
- the extension string- Since:
- JavaMail 1.3.2
-