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
! myusername@gmail.com

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?

  • 5
    Note: Profit-oriented companies generally don't like this. – peterh Feb 12 '15 at 13:09

Use :0c for forwarding a copy of a message

! myusername@gmail.com

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.
  • 1
    I use this setup, but i get into problems with DMARC and some domains. I don't know whose fault it is... "550-5.7.1 Unauthenticated email from dhl.de is not accepted due to domain's 550-5.7.1 DMARC policy. Please contact the administrator of dhl.de domain if 550-5.7.1 this was a legitimate mail. Please visit 550-5.7.1 support.google.com/mail/answer/2451690 to learn about the 550 5.7.1 DMARC initiative. gk8si37023235wjb.257 - gsmtp" – user56452 Dec 23 '16 at 22:50

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_}" myusername@gmail.com
  • 1
    Why would you use a lock file for forwarding email? This is also needlessly complex in a number of ways, but the X-Loop: safety measure is a good idea for preventing mail loops. – tripleee Feb 12 '15 at 9:44
  • I got this from netikka.net/tsneti/info/proctips.php#forward – dexterdev Feb 13 '15 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.