[Mimedefang] Testing for the existence of a header
Nigel Allen
dna at edrs.com.au
Wed Oct 1 23:35:57 EDT 2008
Carrying on from my original problems, I am now faced with something
that so far I have not been able to solve.
I need to test for the existence of a Maildir folder. If they are less
than 6 characters long they are space padded with leading spaces to 6
(don't ask please).
Here is the code:
if (exists($Header{'x-strata-plan'})) {
if(! exists($staff_codes{$Header{'x-strata-plan'}})) {
# pad with spaces to left to at least 6 characters
my $spno = $Header{'x-strata-plan'};
my $pad_spno = sprintf("%6s", $spno);
my $dirname = '"/home/plans/Maildir/.' . $pad_spno . '"';
if (! -d $dirname) {
return action_bounce ("You entered $spno which is an
invalid code. Folder name was $dirname");
}
}
}
I got the "staff_codes" thing working (thanks to previous assistance
here) but when I test the folder part I get the following displayed:
Oct 2 13:24:12 sydsrv01 sendmail[7872]: m923OA78007872: Milter: data,
reject=554 5.7.1 You entered 226 which is an invalid code. Folder name
was "/home/plans/Maildir/. 226"
But the folder definitely exists. Is this something to do with the
difference between ' and "?
If I copy the message portion and test it I get this:
[root at sydsrv01 mail]# ls -ld "/home/plans/Maildir/. 226"
drwxr-xr-x 2 root root 4096 Oct 2 12:47 /home/plans/Maildir/. 226
I get the same result if I use backslashes to escape the spaces instead
of quoting them.
TIA
Nigel.
More information about the MIMEDefang
mailing list