procmail
[Top] [All Lists]

Re: CC: results in extra copy of message when forwarding

2007-02-23 17:28:06
Please reply to list messages on list for the archives.

On Fri, 23 Feb 2007 17:49:52 -0500 Patrick Baldwin
<Patrick(_dot_)Baldwin(_at_)studsvikscandpower(_dot_)com> wrote:

Gerald V. Livingston II wrote:

On Fri, 23 Feb 2007 11:45:06 -0500 Patrick Baldwin
<Patrick(_dot_)Baldwin(_at_)studsvikscandpower(_dot_)com> wrote:


<SNIP>

I'm forwarding a copy of a user's email to gmail.


Actually, you are piping the entire message (including all original
headers) with a changed "To:" header and added "X-Loop:" header back to
sendmail for delivery.

Sorry, I'll try and be more specific next time.

Note the (including ALL original headers) and be VERY glad you paid
attention during the "X-Loop:" part of procmail class.

Oh, if only there had been "procmail class", and not just me, Google,
and procmail.


This seems to be working fine, except when someone
sends something CC: instead of To:, there ends up
being 2 copies of the email in his local INBOX.


[...]


The other copy has a To: line containing
the gmail address we're forwarding to, and
the same CC: line as the first copy.

The procmail file:


[...]


:0c
* !^FROM_DAEMON
* !^FROM_MAILER
* !^X-Loop: to_gmail
| (formail -t -I"To: 
the(_dot_)traveller(_dot_)in(_dot_)black(_at_)gmail(_dot_)com" \
               -A"X-Loop: to_gmail" \
  ) | $SENDMAIL -t


What you have pipes the original message with a new To: header and the
original Cc: header. So, it gets Cc:'d again. 


OK, that makes sense.

If you'd missed out on adding the X-Loop: you'd get a lot more than one
extra copy.

Try this:

|(formail -i"Cc:" -I"To: 
the(_dot_)traveller(_dot_)in(_dot_)black(_at_)gmail(_dot_)com"\
                -A"X-Loop: to_gmail"
  ) |$SENDMAIL -t

-i will preserve the old Cc: header as "Old-Cc:". Use -I if you just want
to drop the Cc: header.


Do you have any suggestions as to which approach would be best?
I don't see any particular reason to retain the Cc: header, but
perhaps I'm missing something.

Neither is "best". It's personal choice. But since you are moving a copy
outside the system you may want to know who it was originally addressed and
CC'd to just by viewing the headers. If you change the " -ITo: the..." to "
-iTo: the..." you would also preserve the original "To:" header as
"Old-To:"

Gerald

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>