Package ch.astorm.smtp4j.core
Class SmtpMessage
java.lang.Object
ch.astorm.smtp4j.core.SmtpMessage
Represents an SMTP message.
-
Constructor Summary
ConstructorsConstructorDescriptionSmtpMessage(String from, List<String> recipients, jakarta.mail.internet.MimeMessage mimeMessage, String rawMimeContent, List<SmtpExchange> exchanges) Creates a newSmtpMessagewith the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionstatic SmtpMessagecreate(String from, List<String> recipients, byte[] mimeMessageContent, List<SmtpExchange> exchanges) Creates a newSmtpMessagewith the specified parameters.Returns the attachments of the MIME message.getBody()Returns the content of the MIME message.getFrom()Returns theFromheader of the MIME message.jakarta.mail.internet.MimeMessageReturns theMimeMessageparsed from the content.Returns the internal raw content received by the SMTP server to parse asMimeMessage.getRecipients(jakarta.mail.Message.RecipientType type) Returns all the recipients of the giventype.Returns the sent date.Returns the raw SMTP exchanges to create this message.Returns theFromparameter specified during the protocol exchange.Returns the list ofToparameters specified during the protocol exchange.Returns theSubjectheader of the MIME message.
-
Constructor Details
-
SmtpMessage
public SmtpMessage(String from, List<String> recipients, jakarta.mail.internet.MimeMessage mimeMessage, String rawMimeContent, List<SmtpExchange> exchanges) Creates a newSmtpMessagewith the specified parameters.- Parameters:
from- The sourceFromparameter value.recipients- The sourceRcptparameter values.mimeMessage- The parsedMimeMessage.rawMimeContent- The raw MIME content ofmimeMessage.exchanges- The raw SMTP exchanges.
-
-
Method Details
-
getSourceFrom
Returns theFromparameter specified during the protocol exchange. This value will contain only the email (info@mydomain.com).- Returns:
- The
MAIL FROM:value. - See Also:
-
getSourceRecipients
Returns the list ofToparameters specified during the protocol exchange. The values will contain only the email (info@mydomain.com).Note that all recipients (including
Message.RecipientType.BCC) will be present in this list.- Returns:
- The
RCPT TO:values. - See Also:
-
getSmtpExchanges
Returns the raw SMTP exchanges to create this message.- Returns:
- The raw SMTP exchanges.
-
getFrom
Returns theFromheader of the MIME message. This value can be composed, for instance:Cédric <info@mydomain.com>.- Returns:
- The
Fromheader.
-
getRecipients
Returns all the recipients of the giventype. Those values can be composed, for instance:Cédric <info@mydomain.com>.The
Message.RecipientType.BCCwill always yield an empty list.- Parameters:
type- The type.- Returns:
- A list of recipients or an empty list if there is none.
-
getSubject
Returns theSubjectheader of the MIME message.- Returns:
- The
Subjectheader.
-
getBody
Returns the content of the MIME message. If the underlyingMimeMessageis aMimeMultipart, then all the parts without a filename will be concatenated together (separated bySmtpProtocolConstants.CRLFand returned as the body. If there is none, then null will be returned.- Returns:
- The content or null.
-
getAttachments
Returns the attachments of the MIME message. If the underlyingMimeMessageis notMimeMultipartan empty list will be returned.Note that only parts with a name will be considered as attachment.
- Returns:
- A list of attachments.
-
getSentDate
Returns the sent date.- Returns:
- The sent date.
-
getMimeMessage
public jakarta.mail.internet.MimeMessage getMimeMessage()Returns theMimeMessageparsed from the content.- Returns:
- the
MimeMessage.
-
getRawMimeContent
Returns the internal raw content received by the SMTP server to parse asMimeMessage.- Returns:
- The raw content.
-
create
public static SmtpMessage create(String from, List<String> recipients, byte[] mimeMessageContent, List<SmtpExchange> exchanges) Creates a newSmtpMessagewith the specified parameters.- Parameters:
from- The sourceFromparameter value.recipients- The sourceRcptparameter values.mimeMessageContent- TheMimeMessagecontent.exchanges- The raw SMTP exchanges of this message.- Returns:
- A new
SmtpMessageinstance.
-