Using procmail forward emails to another account keeping a copy
Asked Answered
T

1

8

I try to use procmail to send copies from all incoming emails to another email account (both of them on the same server, for example email1 and email2 accounts).

My .procmailrc is in email1 account:

:0c
! email2

As fas as I know this should keep a copy in email1 account too. But there is no email in that folder. (The forwarded emails appeared in email2 account correctly.)

How can I solve this problem?

Note: .forward file contains:

| "/usr/bin/procmail"
Takeoff answered 9/5, 2012 at 12:1 Comment(4)
If that's your entire .procmailrc then something in the delivery process is broken. If not, something later on in your .procmailrc is routing the message to a folder you have not been looking at. Try running with LOGABSTRACT=yes and/or VERBOSE=yes. See furthermore partmaps.org/era/mail/procmail-debug.htmlSquires
Thank you, for you help. It was useful. Yes, it is the full .procmailrc file. (Naturally I intend to create a complex procmailrc file in the future.) I set logabstract=yes and verbose=yes and a logfile. I see in the log file, that the emails of email1 is delivered to /var/mail/email1. I dont understand why. I tried to set MAILDIR=$HOME or MAILRDIR=/home/email1 or MAILDIR=/home/email1/Maildir but no success. Note: If I remove .forward and .procmailrc files, emails arrive to /home/email1 correctly.Takeoff
What are the values of $DEFAULT, $ORGMAIL, etc? There's a bunch of these, have a look at partmaps.org/era/procmail/mini-faq.html and/or the procmailrc(5) manual page.Squires
Thank you very much, you pointed the right direction, see my edited question.Takeoff
T
7

This works for me (many thanks to tripleee):
First, I had to set the DEFAULT variable too. (Its default is $ORGMAIL, and ORGMAIL default is /var/mail/$LOGNAME, as described in procmailrc manual Environment variable defaults section.)
Second, I had to set trailing / to the DEFAULT and MAILDIR. (If there is no trailing /, procmail use mbox format and it creates an mbox file like msg.oqs in the specified directory.)

So the full .procmailrc:

DEFAULT=$HOME/Maildir/
MAILDIR=$HOME/Maildir/

:0c
! email2

If you would like to debug, write these rows after MAILDIR:

LOGFILE=$HOME/procmail.log
LOGABSTRACT=yes
VERBOSE=yes
Takeoff answered 11/5, 2012 at 9:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.