smtpprox and postfix

M

Martijn Stam

Hello,

I need to replace our domain name amstec.net 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 amstec.net with the domain name.

Some code snippets:

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

sub spew
{
my ($client, $fh ) = @_;
seek( $fh, 0, 0);
local( *_ );
local( $/ ) = "\r\n";
while ( <$fh> )
{
s/[\r\n]*$//;
$client->say($_);
}
}

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

Martijn Stam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top