sendMessage method Null safety

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

Sends the specified message.

Set use8BitEncoding to true for sending a UTF-8 encoded message body. Specify from in case the originator is different from the From header in the message. Optionally specify the recipients, in which case the recipients defined in the message are ignored.


Future<SmtpResponse> sendMessage(MimeMessage message,
    {bool use8BitEncoding = false,
    MailAddress? from,
    List<MailAddress>? recipients}) {
  final recipientEmails = recipients != null
      ? =>
      : message.recipientAddresses;
  if (recipientEmails.isEmpty) {
    throw SmtpException(this, SmtpResponse(['500 no recipients']));
  return sendCommand(
      SmtpSendMailCommand(message, use8BitEncoding, from, recipientEmails));