Well, its turns out to be quite easy in the end.

There is no required format for the Message Id, so it can be pretty much anything you like, but it does have to be unique. However, as has been noted, the general accepted format of a Message Id is $a(separator)$b@domain_name, where $a is essentially some form of timestamp and $b is some form of random element. So, here is what I created. The timestamp is generated from localtime and a random number from rand().

my @dayofweek = (qw(Sun Mon Tue Wed Thu Fri Sat)); my @monthnames = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)) +; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday, $isdst) = localtime( +); $year += 1900; my $ran_num = int(rand(100000)); #This is a 5 figure random number whi +ch ensures the MID is really, really unique! # Create a Message Id my $MID = sprintf("<%04d:%02d:%s:%s-%02d:%02d:%02d-%05d\@company_name. +com>", $year, $mday, $monthnames[$mon], $dayofweek[$wday], $hour, $min, $sec, + $ran_num);

And this is an example of what $MID looks like:

<2017:21:May:Sun-07:36:11-57049@company_name.com>

spamassassin seemed to think this was ok and so lowered the spam score accordingly, so helping prevent my script-generated emails ending up in the spam folder.

Many thanks to those who replied. I appreciated your comments and suggestions.

Geoffrey


In reply to Re^3: Generating Message_id email headers by astrobal
in thread Generating Message_id email headers by astrobal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.