sendMessageBuilder method
Future
sendMessageBuilder(
- MessageBuilder messageBuilder, {
- MailAddress? from,
- bool appendToSent = true,
- List<
MailAddress> ? recipients,
Sends the message defined with the specified messageBuilder
with the recommended text encoding.
Specify from
as the originator in case it differs from the From
header of the message.
Optionally set appendToSent
to false
in case the message should NOT be appended to the SENT folder.
By default the message is appended. Note that some mail providers automatically apppend sent messages to
the SENT folder, this is not detected by this API.
Optionally specify the recipients
, in which case the recipients defined in the message are ignored.
Implementation
Future<dynamic> sendMessageBuilder(
MessageBuilder messageBuilder, {
MailAddress? from,
bool appendToSent = true,
List<MailAddress>? recipients,
}) async {
final supports8Bit = await supports8BitEncoding();
final builderEncoding =
messageBuilder.setRecommendedTextEncoding(supports8Bit);
final message = messageBuilder.buildMimeMessage();
final use8Bit = (builderEncoding == TransferEncoding.eightBit);
final futures = <Future>[];
futures.add(_sendMessageViaOutgoing(message, from, use8Bit, recipients));
if (appendToSent && _incomingMailClient.supportsAppendingMessages) {
futures.add(appendMessageToFlag(message, MailboxFlag.sent,
flags: [MessageFlags.seen]));
}
return Future.wait(futures);
}