[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: (v) ugly (and simple) bash script...



Greg Wooledge wrote: 
> On Sat, May 21, 2022 at 10:08:42AM +0100, Morgan Read wrote:
> > I've come up with:
> > `cd ~/Maildir/new/; for f in *; do mv -- "$f" ~/Maildir/cur/"${f%}.eml"; cd
> > -; done`
> 
> You aren't checking whether the first cd succeeds.  If it fails for any
> reason, you're going to end up moving file(s) out of wherever you happen
> to be at the time.

This looks like a bizarre kind of Maildir delivery recipe that
would better be handled by a proper delivery tool; I generally
recommend the maildrop package, which supplies an excellent mail
filtering language.


> > Getting postfix to run that command on mail delivery is the next question?
> 
> Now that looks like something closer to an actual goal statement.  I
> still don't understand why you want messages to be marked as "not new"
> and given a different filename, but presumably there is some rationale
> for it.
> 
> I don't know postfix, but presumably what you want to do here is find
> whatever mechanisms or hooks it has for performing local mail deliveries.

Postfix can either hand this off globally, per address, or
per-user. Per-user config is set up in ~/.forward which at its simplest
is one line per delivery, e.g.:

|/usr/bin/maildrop

Documentation is in `man 8 local`
http://www.postfix.org/local.8.html

> I'm guessing postfix has something similar to this.  You'll have to read
> up on it yourself.  Pay close attention to how postfix interprets the
> exit status of the programs that you run, and make sure you exit with
> an appropriate status.

This is in the man section on EXTERNAL COMMAND DELIVERY.

-dsr-


Reply to: