MessageBuilder class Null safety

Simplifies creating mime messages for sending or storing.

Inheritance

Constructors

MessageBuilder({String? text, TransferEncoding transferEncoding = TransferEncoding.automatic, CharacterSet? characterSet, ContentTypeHeader? contentType, HeaderEncoding subjectEncoding = HeaderEncoding.Q})
Creates a new message builder and populates it with the optional data. [...]

Properties

attachments List<AttachmentInfo>
final, inherited
bcc List<MailAddress>?
bcc recpients
read / write
cc List<MailAddress>?
cc recpients
read / write
characterSet CharacterSet?
read / write, inherited
chatGroupId String?
Specify in case this is a chat group discussion
read / write
contentDisposition ContentDispositionHeader?
read / write, inherited
contentType ContentTypeHeader?
read / write, inherited
date DateTime?
Message date
read / write
from List<MailAddress>?
List of senders, typically this is only one sender
read / write
hasAttachments bool
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
isChat bool
Set to true to set chat headers
read / write
messageId String?
ID of the message
read / write
originalMessage MimeMessage?
Reference to original message
read / write
replyToSimplifyReferences bool
Set to true in case only the last replied to message should be referenced. Useful for long threads.
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
sender MailAddress?
One sender in case there are different from senders
read / write
subject String?
Message subject
read / write
subjectEncoding HeaderEncoding
Header encoding type
read / write
text String?
read / write, inherited
to List<MailAddress>?
to recpients
read / write
transferEncoding TransferEncoding
read / write, inherited

Methods

addBinary(Uint8List data, MediaType mediaType, {TransferEncoding transferEncoding = TransferEncoding.base64, ContentDispositionHeader? disposition, String? filename}) PartBuilder
Adds a binary data part with the given data and optional filename. [...]
inherited
addFile(File file, MediaType mediaType, {ContentDispositionHeader? disposition}) Future<PartBuilder>
Adds the file part asyncronously. [...]
inherited
addHeader(String name, String value, {HeaderEncoding encoding = HeaderEncoding.none}) → void
Adds a header with the specified name and value. [...]
inherited
addMailAddressHeader(String name, List<MailAddress> addresses) → void
Adds another header with the specified name with the given mail addresses as its value
inherited
addMessagePart(MimeMessage mimeMessage, {ContentDisposition disposition = ContentDisposition.attachment}) PartBuilder
Adds the message mimeData as a message/rfc822 content with the given subject as its filename. [...]
inherited
addMultipartAlternative() PartBuilder
Adds a part with the multipart/alternative subtype. [...]
inherited
addPart({ContentDispositionHeader? disposition, MimePart? mimePart, MediaSubtype? mediaSubtype, bool insert = false}) PartBuilder
Adds a new part [...]
inherited
addRecipient(MailAddress recipient, {RecipientGroup group = RecipientGroup.to}) → void
Adds a recipient. [...]
addText(String text, {MediaType? mediaType, TransferEncoding transferEncoding = TransferEncoding.automatic, CharacterSet characterSet = CharacterSet.utf8, ContentDispositionHeader? disposition, bool insert = false}) PartBuilder
Adds a text part to this message with the specified text. [...]
inherited
addTextHtml(String text, {TransferEncoding transferEncoding = TransferEncoding.automatic, CharacterSet characterSet = CharacterSet.utf8, ContentDispositionHeader? disposition, bool insert = false}) PartBuilder
Adds a HTML text part [...]
inherited
addTextPlain(String text, {TransferEncoding transferEncoding = TransferEncoding.automatic, CharacterSet characterSet = CharacterSet.utf8, ContentDispositionHeader? disposition, bool insert = false}) PartBuilder
Adds a plain text part [...]
inherited
buildMimeMessage() MimeMessage
Creates the mime message based on the previous input.
clearRecipients() → void
Removes all recipients from this message. [...]
getPart(MediaSubtype mediaSubtype, {bool recursive = true}) PartBuilder?
Retrieves the first builder with the specified mediaSubtype. [...]
inherited
getTextHtmlPart() PartBuilder?
Retrieves the first builder with a text/plain part. [...]
inherited
getTextPlainPart() PartBuilder?
Retrieves the first builder with a text/plain part. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
removeAttachment(AttachmentInfo info) → void
Removes the specified attachment info
inherited
removeHeader(String name) → void
Removes the header with the specified name. [...]
inherited
removePart(PartBuilder childBuilder) → void
Removes the specified part childBuilder
inherited
removeReadReceiptRequest() → void
Removes the read receipt request. [...]
removeRecipient(MailAddress recipient) → void
Removes the specified recipient from To/Cc/Bcc fields. [...]
requestReadReceipt({MailAddress? recipient}) → void
Requests a read receipt by setting the Disposition-Notification-To header to from address. [...]
setContentType(MediaType mediaType, {CharacterSet? characterSet, String? multiPartBoundary, String? name, Map<String, String>? parameters}) → void
Creates the content-type based on the specified mediaType. [...]
inherited
setHeader(String name, String? value, {HeaderEncoding encoding = HeaderEncoding.none}) → void
Sets a header with the specified name and value, replacing any previous header with the same name. [...]
inherited
setMailAddressHeader(String name, List<MailAddress> addresses) → void
Adds the header with the specified name with the given mail addresses as its value
inherited
setRecommendedTextEncoding(bool supports8BitMessages) TransferEncoding
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited

Static Methods

buildReadReceipt(MimeMessage originalMessage, MailAddress finalRecipient, {String reportingUa = 'enough_mail', bool isAutomaticReport = false, String subject = 'read receipt', String textTemplate = MailConventions.defaultReadReceiptTemplate}) MimeMessage
Builds a disposition notification report for the given originalMessage that has been received by the finalRecipient. [...]
buildSimpleTextMessage(MailAddress from, List<MailAddress> to, String text, {List<MailAddress>? cc, List<MailAddress>? bcc, String? subject, HeaderEncoding subjectEncoding = HeaderEncoding.Q, DateTime? date, MimeMessage? replyToMessage, bool replyToSimplifyReferences = false, String? messageId, bool isChat = false, String? chatGroupId, CharacterSet characterSet = CharacterSet.utf8, TransferEncoding transferEncoding = TransferEncoding.quotedPrintable}) MimeMessage
Creates a text message. [...]
createForwardSubject(String originalSubject, {String defaultForwardAbbreviation = MailConventions.defaultForwardAbbreviation}) String
Creates a subject based on the originalSubject taking mail conventions into account. [...]
createMessageId(String? hostName, {bool isChat = false, String? chatGroupId}) String
Generates a message ID [...]
createRandomId({int length = 18}) String
Creates a new randomized ID text. [...]
createReplySubject(String originalSubject, {String defaultReplyAbbreviation = MailConventions.defaultReplyAbbreviation}) String
Creates a subject based on the originalSubject taking mail conventions into account. [...]
encodeHeaderValue(String value, [TransferEncoding transferEncoding = TransferEncoding.quotedPrintable]) String
Encodes the specified header value. [...]
encodeText(String text, TransferEncoding transferEncoding, [CharacterSet characterSet = CharacterSet.utf8]) String
Encodes the specified text with given transferEncoding. [...]
fillTemplate(String template, MimeMessage message, {Map<String, String>? parameters}) String
Fills the given template with values extracted from the provided message. [...]
fromContentTransferEncodingName(String name) TransferEncoding
getCharacterSetName(CharacterSet? characterSet) String
Retrieves the name of the specified characterSet.
getCodec(CharacterSet? characterSet) Codec
Rerieves the codec for the specified characterSet.
getContentTransferEncodingName(TransferEncoding encoding) String
Retrieves the name of the specified encoding.
prepareForwardMessage(MimeMessage originalMessage, {MailAddress? from, String forwardHeaderTemplate = MailConventions.defaultForwardHeaderTemplate, String defaultForwardAbbreviation = MailConventions.defaultForwardAbbreviation, bool quoteMessage = true, HeaderEncoding subjectEncoding = HeaderEncoding.Q, bool forwardAttachments = true}) MessageBuilder
Prepares to forward the given originalMessage. Optionallyspecify the sending user with from. You can also specify a custom forwardHeaderTemplate. The default MailConventions.defaultForwardHeaderTemplate contains the metadata information about the original message including subject, to, cc, date. Specify the defaultForwardAbbreviation if not Fwd should be used at the beginning of the subject to indicate an reply. Set quoteMessage to false when you plan to quote text yourself, e.g. using the enough_mail_html's package quoteToHtml() method. Set forwardAttachments to false when parts with a content-disposition of attachment should not be forwarded.
prepareFromDraft(MimeMessage draft) MessageBuilder
Prepares a message builder from the specified draft mime message.
prepareMailtoBasedMessage(Uri mailto, MailAddress from) MessageBuilder
Convenience method for creating a message based on a mailto URI from the sender specified in from. [...]
prepareMessageWithMediaType(MediaSubtype subtype, {TransferEncoding transferEncoding = TransferEncoding.eightBit}) MessageBuilder
Convenience method for initiating a message with the specified media subtype [...]
prepareMultipartAlternativeMessage({TransferEncoding transferEncoding = TransferEncoding.eightBit}) MessageBuilder
Convenience method for initiating a multipart/alternative message [...]
prepareMultipartMixedMessage({TransferEncoding transferEncoding = TransferEncoding.eightBit}) MessageBuilder
Convenience method for initiating a multipart/mixed message [...]
prepareReplyToMessage(MimeMessage originalMessage, MailAddress from, {bool replyAll = true, bool quoteOriginalText = false, bool preferPlainText = false, String replyHeaderTemplate = MailConventions.defaultReplyHeaderTemplate, String defaultReplyAbbreviation = MailConventions.defaultReplyAbbreviation, bool replyToSimplifyReferences = false, List<MailAddress>? aliases, bool handlePlusAliases = false, HeaderEncoding subjectEncoding = HeaderEncoding.Q}) MessageBuilder
Prepares to create a reply to the given originalMessage to be send by the user specifed in from. [...]
quotePlainText(String header, String? text) String
Quotes the given plain text header and text.