Skip to content

Commit

Permalink
create an email message with a proper Message-ID (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigio committed May 31, 2024
1 parent ac6d3ad commit e04285e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/Mail/DMARC/Report/Send/SMTP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ sub assemble_message_object {
],
parts => [@parts],
) or croak "unable to assemble message\n";
$email->header_str_set( 'Message-ID' => $self->get_message_id );

return $email;
}
Expand All @@ -196,6 +197,24 @@ sub get_helo_hostname {
return Sys::Hostname::hostname;
};

sub get_message_id {
my $self = shift;
my $host = $self->get_helo_hostname;

my ($ss, $mm, $hh, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);

# Generate a "random" Message-ID
return sprintf("<%04d%02d%02d%02d%02d.%s\@%s>\n",
$year + 1900,
$mon + 1,
$mday,
$hh,
$mm,
rand(),
$host
);
}

1;

__END__
Expand Down

0 comments on commit e04285e

Please sign in to comment.