novitiate <novi...@perlmonk.org> writes:
Is there a way to return the message's Maildir filename
and capture it in a variable ? I am trying to create a db of
messages and would like to do something like:
xfilter "perlscript $MESG_FILE_NAME $To $From $Subject"
to Maildir/.folder
The problem with this is that the filename is not known until the actual
to/cc happens. It is calculated based on the pid, time, inode, etc.
You can look in maildrop/maildir.C to see where it actually figures out the
filename (it's a variable called buf, the code appends things to it until the
filename is complete). Putting in a fprintf(stderr, "Maildir is %s\n", buf);
and then having the perl script be a wrapper AROUND maildrop that does
$var = `maildrop /path/to/.malfilter 2>&1`;
@array = split /\n/, $var;
foreach (@array) {
if(/^Maildir is (.*)$/) {
$filename = $1;
do_database_storage($filename);
exit;
}
}
print "There was no maildir delivery\n";
would be as close as you could get, I think.
Though, come to think of it, you'd have to do both reading and writing to the
maildrop process. perldoc Open3, iirc.
where perlscript would simply input these parameters into some
SQL code. The end goal is to have an application the can use the SQL
info to forward messages by referencing the filename -- this way I don't
have to process message info twice (maildrop will do it once) and i get
a unique key and file reference all at the same time.
There's gonna be a whole lotta work involved in this project, from the sounds
of it :p