decodeSender method

List<MailAddress> decodeSender({
  1. bool combine = false,
})

Retrieves the sender of the this message

by checking the reply-to, sender and from header values in this order.

Set combine to true in case you want to combine the addresses from these headers, by default the first non-empty entry is returned.

Implementation

List<MailAddress> decodeSender({bool combine = false}) {
  var replyTo = decodeHeaderMailAddressValue('reply-to') ?? <MailAddress>[];
  if (combine || (replyTo.isEmpty)) {
    final senderValue =
        decodeHeaderMailAddressValue('sender') ?? <MailAddress>[];
    if (combine) {
      replyTo.addAll(senderValue);
    } else {
      replyTo = senderValue;
    }
  }
  if (combine || replyTo.isEmpty) {
    final fromValue = decodeHeaderMailAddressValue('from') ?? <MailAddress>[];
    if (combine) {
      replyTo.addAll(fromValue);
    } else {
      replyTo = fromValue;
    }
  }
  return replyTo;
}