sendChunkedMessage method

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

Sends the specified message using the BDAT SMTP command.

BDATA is supported when the SMTP server announces the CHUNKING capability in its EHLO response. You can query SmtpServerInfo.supportsChunking for this.

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.

Implementation

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