On Sat, Feb 18, 2023 at 05:58:57PM +0000, Thomas Weißschuh wrote:
> On Fri, Feb 17, 2023 at 10:28:28AM +0000, Eric Wong wrote:
> > It's a tragedy that mutt changed their default Message-ID format :<
> > Newer versions allow overriding $message_id_format in muttrc,
> > but mutt 2.0.5 in Debian 11 won't have it.
> > 
> > Fwiw, I run mutt on several machines/arches/OSes, getting them
> > all to the same new version of mutt will take many years and I
> > don't want compile + keep numerous binaries up-to-date in the
> > mean time.
> 
> Note:
> 
> You can also use mutt's builtin facilities to get custom
> Message-IDs.
> 
> # in muttrc
> send-hook . "source ./msgid"

One mistake: This needs to be the full path to the "msgid" config:

> send-hook . "source ~/.config/mutt/msgid"

> # in file "msgid" next to muttrc
> # put any command within the backticks
> my_hdr Message-ID: <`uuidgen -r`@t-8ch.de>
> 
> The extra config file and "source" command are needed to force
> reevaluation of the backticks for each message.
> 
> This should also work in older versions of mutt and has the advantage
> that mutt knows about the actual Message-ID, for example showing it with
> edit_headers=yes.
> 
> > I also use msmtp and distribute my muttrc + ~/bin to all of
> > them, so I wrote this msmtp wrapper which is mutt-version-agnostic:
> > 
> > $ cat $HOME/bin/msmtp-msgid
> > eval 'exec perl -w -S $0 ${1+"$@"}'
> > if 0; # running under some shell
> > # in muttrc:
> > # set sendmail = msmtp-msgid
> > use v5.12;
> > my ($hdr, $bdy) = split(/\n\n/, do { local $/; <STDIN> }, 2);
> > if ($hdr !~ /^Message-ID:\s*<\d{14}\b/aims) {
> >     my $h;
> >     if ($hdr =~ /^Message-ID:[^@]+\@([^>]+)>/ims) {
> >             $h = $1;
> >     } else {
> >             require Sys::Hostname;
> >             $h = Sys::Hostname::hostname();
> >     }
> >     require POSIX;
> >     require Time::HiRes;
> >     my ($time, $msec) = Time::HiRes::gettimeofday();
> >     my $msgid = POSIX::strftime("%Y%m%d%H%M%S.M$msec", gmtime($time));
> >     $hdr =~ s/^Message-ID:[^\n]+/Message-ID: <$msgid\@$h>/msi;
> > }
> > my $pid = open(my $fh, '|-', 'msmtp', @ARGV) // die "popen: $!";
> > print $fh $hdr, "\n\n", $bdy or die "print $!";
> > close $fh or die "msmtp \$?=$?";
> > __END__

Reply via email to