Reputation: 154
This forwards emails to the address stored in the variable EMAIL_ADDR
:0
* ^From
! $EMAIL_ADDR
I would like to save a local copy of the email before it's forwarded. Not sure of the syntax to do that. I know this doesn't do it:
:0
* ^From
| tee $FILE
! $EMAIL_ADDR
Upvotes: 0
Views: 1297
Reputation: 10913
Try the script below (It is based on man procmailex
).
:0
* ^From
{
# use lock file to prevent simultaneous deliveries
:0 c:tee.lock
| tee $FILE
:0
! $EMAIL_ADDR
}
Instead of | tee $FILE
you may use directly name of mailbox-file
Upvotes: 0
Reputation: 189789
The common approach is to use a "clone" flag.
:0c
! $EMAIL_ADDR
# Whatever else you want to do with the message
:0:
$FILE
Since every message has a ^From
I assume you were simply not aware that the condition is optional; to unconditionally do something, just omit the condition regex line completely. If that's not the case, you can group multiple action under a condition with a block of recipes in braces:
:0
* common condition
{
:0c
! $EMAIL_ADDR
:0:
$FILE
}
This is an ancient FAQ; http://www.iki.fi/era/procmail/mini-faq.html#c-flag
You can have multiple conditions, but only one action. If you like, you could use tee
to save a copy to a file, then pipe to $SENDMAIL
instead; but I would recommend against that, because the tee
output file needs to have a lock file, in order to prevent multiple Procmail processes from delivering interleaved fragments of multiple messages to the same file at the same time; see http://www.iki.fi/era/procmail/mini-faq.html#locking for example.
Upvotes: 1