poste.io

complete mail server built in docker
Open source plugins for QPSMTPD:

Remove headers


Download
#!perl -w
 
=head1 NAME
 
remove_headers - remove headers from outgoing emails due privacy or redundancy
 
=head1 AUTHOR
 
Copyright (c) 2015 Stanislav Humplik (stanislav@analogic.cz)
 
This plugin is free software; you can distribute it and/or modify it
under the terms of the General Public License v3.
 
=cut
 
 
use strict;
use warnings;
 
use Qpsmtpd::Constants;
use Qpsmtpd::DSN;
 
sub hook_queue_pre {
    my ($self, $transaction) = @_;
 
    if($self->is_immune) {
 
 
        $transaction->header->delete('Authentication-Results');
        # privacy
 
        $transaction->header->delete('X-Virus-Checked');
        $transaction->header->delete('X-Virus-Found');
        # rendundant, if virus found we block transaction anyway
 
        $transaction->header->delete('X-HELO');
        # privacy
 
        $transaction->header->delete('User-Agent');
        # privacy
 
        my $received = $transaction->header->get('Received');
        $transaction->header->delete('Received');
 
        my $me = $self->qp->config('me');
 
        $received =~ s/from ([^ ]+)/from $me/;
        $received =~ s/HELO ([^ \)]+)\)\s*\([^ \)]+\)/HELO $me\) \(127.0.0.1\)/;
 
        $transaction->header->add('Received', $received);
    }
 
    return OK;
}