+
+ # Only use Sender: if From is not present
+ foreach my $h (qw(From Sender)) {
+ my @v = $hdr->header($h);
+ if (@v) {
+ digest_addr($dig, $h, $_) foreach @v;
+ }
+ }
+ foreach my $h (qw(Subject Date)) {
+ my @v = $hdr->header($h);
+ foreach my $v (@v) {
+ utf8::encode($v);
+ $dig->add("$h\0$v\0");
+ }
+ }
+ # Some mail processors will add " to unquoted names that were
+ # not in the original message. For the purposes of deduplication,
+ # do not take it into account:
+ foreach my $h (qw(To Cc)) {
+ my @v = $hdr->header($h);
+ digest_addr($dig, $h, $_) foreach @v;
+ }
+ msg_iter($mime, \&content_dig_i, $dig);
+ $dig;
+}
+
+sub content_id ($) {
+ content_digest($_[0])->digest;