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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.