smtpprox and postfix

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


I need to replace our domain name for a couple of domain names in
the e-mail headers.
I use smtpprox as transparent proxy now, but I'm not able to modify the
script to do a find and replace.

What it has to do:

1. Find the domain name part of the To address in the e-mail headers.
2. Split the domain name on domain and extension
3. Read the content of a text file or preferable a MySQL database and if the
domain name from the To address is in the file/database then replace all
instances of with the domain name.

Some code snippets:

while (1) {
    my $client = MSDW::SMTP::Client->new(interface => $dstaddr, port =>
    my $banner = $client->hear;
    $banner = "220 $debugtrace.$$" if defined $debugtrace;
    while (my $what = $server->chat) {
        if ($what eq '.') {
            spew ( $client, *PREPEND ) if defined($prependheader);
            #spew ( $client );
        } else {
    $client = undef;
    delete $server->;
    exit 0 if $lives-- <= 0;

sub spew
 my ($client, $fh ) = @_;
 seek( $fh, 0, 0);
 local( *_ );
 local( $/ ) = "\r\n";
 while ( <$fh> )

This example adds extra headers read from an external file. It needs to be
modified to do a find and replace.

Martijn Stam

Site Timeline