Re: delivery blocked messages

Lampa <[email protected]>
Newsgroups gmane.mail.qmail.scanner
Message-ID <[email protected]>
Hello,

thanks for script. I look at script and does in easier way same thing
as my script. So i little chenged my script and commented it, so it
can be used by other people. But i think that will be better if some
perl programmer take look at this. Syntax is doruc.pl <directory with
emails> [go] Program runs default in debug mode (eg not injecting
emails only showing what will be done) after 2nd argument "go" is
specified emails will be sent.
---
Lampa

2007/5/21, Scooter Chanman <[email protected]>:
> I see the attachment that you sent me in the other message. Here is the one
> that I have been using for a year now with no problem.
>
> Scott
>
> Lampa <[email protected]> wrote:
>  Date: Mon, 14 May 2007 20:37:54 +0200
> From: Lampa <[email protected]>
> To: [email protected]
> Subject: [Qmail-scanner-general] delivery blocked messages
>
>  Hi,
>
> is there some way (no by hand) to deliver blocked (quarantined)
> messages to recipient (eg. remove *** Qmail-Scanner Quarantine
> Envelope Details Begin/End *** stuff and insert into qmail queue) ?
>
> Thank you for your advice.
> ---
>
> Lampa
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Qmail-scanner-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qmail-scanner-general
>
>
>
>  ________________________________
> Pinpoint customers who are looking for what you sell.
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Qmail-scanner-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qmail-scanner-general
>
>
>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Qmail-scanner-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qmail-scanner-general
doruc.pl (application/octet-stream, 1.9 KB)
#!/usr/bin/perl

use strict 'vars';

if ($#ARGV != 0 && $#ARGV != 1) {
	print "Usage: $0 <directory> [go]\n";
	exit 1;
}

# specify dir with emails
chdir($ARGV[0]) || die("Cannot change directory to $ARGV[0]\n");

# path to qmail-inject
my $qmailinject = '/usr/local/qmail/bin/qmail-inject';

my ($debug) = 1;
my ($param, $soubor) = '';
my (@HLAVICKY) = ();

$debug = 0 if ($ARGV[1] eq "go");
$param .= " -n" if ($debug);

# read entire directory
opendir(DIR, ".") || die("Cannot read directory $ARGV[0]\n");

foreach $soubor (readdir(DIR)) {
	# email should be file
	if (!-f $soubor) {
		next;
	}
	# get headers from qmail-scanner
	@HLAVICKY = `tail -6 $soubor 2> /dev/null`;

	my ($odesilatel, $radek, $prijemci) = '';
	my ($odes, $prij) = 0;

	# extract sender and recipient(s)
	foreach $radek (@HLAVICKY) {
		if ($radek =~ /^X-Qmail-Scanner-Mail-From: \"(.*)\" via/) {
			$odesilatel = $1;
			$odes = 1;
		}
		if ($radek =~ /^X-Qmail-Scanner-Rcpt-To: \"([^\s]+)\"$/) {
			$prijemci = $1;
			$prij = 1;
		}
	}

	# send only if we have sender and at least one recipient
	if ($odes == 1 && $prij == 1) {
		my ($obsah) = '';
		# read file only once
		open(SOUBOR, "<$soubor");
		while (<SOUBOR>) {
			if (!/^\*\*\* Qmail-Scanner Quarantine Envelope Details Begin \*\*\*/) {
				$obsah .= $_;
			} else {
				last;
			}
		}
		close(SOUBOR);

		my ($prijemce) = '';

		# multiple recipients separated by coma
		foreach $prijemce (split(/\,/, $prijemci)) {
			$prijemce =~ s/^\s//g;
			$prijemce =~ s/\s$//g;
			$prijemce =~ s/,$//;

			# print what we are doing and do it
			print "*** Sending file $soubor: $odesilatel -> $prijemce *** ($qmailinject$param -f $odesilatel $prijemce)\n";
			open(QI, "|$qmailinject$param -f $odesilatel $prijemce") || die("Cannot execute qmail-inject\n");
			print QI $obsah;
			close(QI);
		}
	}
}

closedir(DIR);

exit;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.