Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to discard the original message content in bounced mail

Status
Not open for further replies.

yuenlok

Technical User
Nov 20, 2002
18
CA
I use user bulletin to send newsletters everyweek. All bounced back mails will go to user bulletin's Mailbox and contain a copy of the original messages. Is there any way to control qmail to discard the original message content of a bounce mail to a specific user? For other users, I hope to keep the content.

Thanks for taking the time to help.
 
Hello Yuenlok,

instead of the user "bulletin", I would use a different sender mailaddress and set up an alias for that address:
~alias/.qmail-bullbounce

Every mail that returns goes to bullbounce, you forward through a programm by putting "|/home/bulletin/bin/mail.pl" in ~alias/.qmail-bullbounce.

You can write a little Perl program to handle this:

#!/usr/bin/perl -w

use strict;
use Net::SMTP;

{
my $server = 'mailer.fredman.com';
my $sender = 'bullbounce@fredman.com';
my $receiver = 'bulletin@fredman.com';
my $smtp;
$smtp = Net::SMTP->new($server);
$smtp->mail($sender);
$smtp->to($receiver);
$smtp->data();
$smtp->datasend("From: $sender\n");
$smtp->datasend("To: $receiver\n");
$smtp->datasend("Subject: bounce-mail\n");
$smtp->datasend("\n");
$smtp->datasend(mailtext());
$smtp->dataend();
$smtp->quit();
}

sub mailtext {
my @mail;
while(<>) {
last if($_ eq 'Original message follows.');
push @mail, $_;
}
return @mail;
}


I hope this will do the job for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top