Forwarding my institute mail to gmail?

I wanted to forward emails which comes to my institute mail to my gmail, while keeping the originals in the institute account too. I tried editing my /.procmail file like below:

# Forward everything to me at gmail

This was working fine except the original mail is just bouncing to gmail account, not getting stored at institute mail account. What to do for this?

Asked By: dexterdev


I got a method from this link. But I dont know if it has any pitfalls.

FROM_=`formail -c -I"Reply-To:" -rt -xTo: 
  | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
SUBJ_=`formail -xSubject: 
       | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`

# Make a copy of all email to my second address
* ! ^X-Loop: myid@myhost.mydom
  | formail -A"X-Loop: myname@institute.domain" 
    -I"Subject: ${SUBJ_} [autofwd]" 
    | ${SENDMAIL} -f"${FROM_}"
Answered By: dexterdev

Use :0c for forwarding a copy of a message


c flag documentation:

c    Generate  a  carbon  copy  of this mail.  This only makes sense on delivering recipes.  The only
        non-delivering recipe this flag has an effect on is on a nesting block, in order to  generate  a
        carbon  copy  this  will  clone  the running procmail process (lockfiles will not be inherited),
        whereby the clone will proceed as usual and the parent will jump across the block.
Answered By: zuberuber
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.