Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have determined that a piece of external software generates emails with the same Message-ID field. This software uses sendmail to perform the actual sending.

Since it is not very easy for us to change that external software to fix the bug, I would like to know if it is possible to make sendmail ignore the given Message-ID and generate a new one?


I have found some documentation confirming my fears:

Header flags only control header insertion . If a header is received in the input, it is passed to the output, regardless of the flag settings.

See, section 10.5.7 Defining Mail Headers

share|improve this question

if you're open to using a different MTA or at least an intermediate MTA, have a look at qpsmtpd. i currently use qpsmtpd to convert incoming uuencoded emails from some legacy apps we use to MIME.

here's what i use, which is a modified version of the tnef2mime plugin (so please ignore any extra cruft and references to tnef2mime). this could be easily modified to remove the existing message-id header and add a new one.

#!/usr/bin/perl -wT

use MIME::Parser;
use MIME::Entity;
use MIME::Head;
use File::MMagic;
use Convert::TNEF;

my $parser;
my $ent;
my $tmpdir='/var/spool/qpsmtpd';
my $count=0;
my $foundtnef=0;
my (@attachments, @blocked, @tnefs);

sub register {
  my ($self, $qp, %arg) = @_;
  $self->register_hook("data_post", "tnef2mime");

sub tnef2mime ( $$ )
        my ($self, $transaction) = @_;
        # new Parser Object
        $parser = new MIME::Parser;
        # temp output directory
        $parser->output_under( $tmpdir );

        # read message body
        open BFN, $transaction->body_filename();
        $ent = $parser->parse(\*BFN);
        close BFN;

        my $founduu = $ent->parts && !$transaction->header->get('MIME-Version');

        if( $founduu )
                $transaction->header->add('MIME-Version', "1.0" );
                my $xac = "UUENCODE -> MIME";
                $self->log(LOGDEBUG, "uuencoded attachment converted to MIME" );
                $transaction->header->add('X-TNEF2MIME-Plugin', $xac );

                # fix content-type header
                $transaction->header->add('Content-Type', $ent->head->get('Content-Type'));

                # write converted message body
                open BFN, ">" . $transaction->body_filename();
                close BFN;


        my $output_dir = $parser->output_dir;

        opendir( DIR, $output_dir ) or die "Could not open temporary output dir $output_dir: $!\n";
        while( defined( my $file = readdir( DIR ) ) )
                next if $file =~ /^\.\.?$/;
                $file =~ s/(^.*$)//;
                $file = $1;
                unlink( "$output_dir/$file" );
        closedir( DIR );
        rmdir( $output_dir );

        return DECLINED;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.