sendMessage method Null safety

Future<void> sendMessage(
  1. MimeMessage message,
  2. {MailAddress? from,
  3. bool appendToSent = true,
  4. bool use8BitEncoding = false,
  5. List<MailAddress>? recipients}
)

Sends the specified message.

Use MessageBuilder to create new messages. 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. You can also specify if the message should be sent using 8 bit encoding with use8BitEncoding, which default to false. Optionally specify the recipients, in which case the recipients defined in the message are ignored.

Implementation

Future<void> sendMessage(
  MimeMessage message, {
  MailAddress? from,
  bool appendToSent = true,
  bool use8BitEncoding = false,
  List<MailAddress>? recipients,
}) {
  final futures = <Future>[];
  futures.add(
      _sendMessageViaOutgoing(message, from, use8BitEncoding, recipients));
  if (appendToSent && _incomingMailClient.supportsAppendingMessages) {
    futures.add(appendMessageToFlag(message, MailboxFlag.sent,
        flags: [MessageFlags.seen]));
  }
  return Future.wait(futures);
}