What I'm trying to do is to forward all the emails that are stored (moved) into a specific user folder to a predefined email address
e.g.
Any new email stored in /home/mycooluser/mail/spam-mail to be forwarded [email protected].
I'm trying to achieve this with some procmail config the issue is that messages needs to be zipped up and sent as an attachment.
Can anybody shed some light on how I could achieve this?
The context in which Procmail runs is when you are in the middle of receiving a new message. Inside your
.procmailrc
you typically don't know yet where the message you are delivering will be stored, because deciding that is now the job of Procmail. Once it has made the decision, it can be made to perform additional actions; but your requirement to zip a folder seems out of place for this kind of logic. I imagine you don't want to zip and send the whole folder every time one new message is added to it...?A more natural implementation would be a periodic cron job. Decide how often it needs to run (hourly? nightly?) and have it erase the messages it successfully zips and sends. If there are no messages in the folder since the previous run, obviously don't zip or send anything.
If indeed you do want to use Procmail for this after all, the logic looks something like
If
Foldername
is a maildir folder, lose the colon after the:0
and adjust the folder name to the correct syntax (maildir folders don't require locking).!
simply forwards without zipping. It's not hard to look up how to also zip but I won't develop this further as I imagine this isn't really what you want or need, as explained above.