Forwarding IMAP email to a Gmail account
February 24, 2017 2:25 PM   Subscribe

I have an email account that is accessible only via IMAP. It does not support automated forwarding. I would like to scrape all of the emails from this account and forward them to my Gmail account.

I'd like for the emails to arrive in my Gmail account with all headers intact such that they're basically identical to the emails that originally arrived in the IMAP account (same to:, from:, reply-to: fields, etc.).

I have a Mac Mini online 24/7 that I can use as a server. I'm relatively comfortable with the command line and with Unix utilities. But I can't find good, coherent instructions on how to get this done. Is this a job for Fetchmail? Does Procmail have to be involved, too? Can anyone point me to an easy guide for setting this up?
posted by mr_roboto to Computers & Internet (5 answers total) 1 user marked this as a favorite
 
Is this a one time operation or do you want to continue to receive e-mail in the IMAP only acct and have it automatically forwarded to the gmail acct?
posted by metadave at 3:09 PM on February 24, 2017


Response by poster: I want to run the scrape continuously in the background, maybe checking for new mail every 20 seconds or so.
posted by mr_roboto at 3:11 PM on February 24, 2017


I setup gmail to simply check my imap email and download a copy in the Accounts setting. Is there a reason why this wouldn't work for you?
posted by advicepig at 3:22 PM on February 24, 2017 [2 favorites]


Best answer: Okay, I'm not 100% sure that this meets your all headers requirement, but the following will handle all IMAP email, keep the original headers intact, but then add redirect headers.

Basically, use Mail.app on your Mac Mini. Set it up to access the IMAP account. Put a rule in place that redirects all mail — make sure you choose "Redirect Message," not "Forward Message" — to the Gmail account.

I've just tested it on my own setup and it works fine. The redirecting means that the reply-to address in Gmail will show as the original sender, not the IMAP email address.

This method allows you to leave the message in the IMAP inbox, if you want, unread and untouched. Alternately, it allows you to add "Delete Message" in the rule after "Redirect Message" so you don't have to worry about mailbox size limits (but you will have to set the "Mailbox Behaviors" "Trash Mailbox" setting in the account settings to erase the deleted messages after some period of time).

advicepig, Gmail does not fetch mail from IMAP accounts. You are probably getting it via POP3.
posted by Mo Nickels at 3:27 PM on February 24, 2017


Response by poster: Much easier than I thought it would be! And it almost works. There are some formatting issues with the redirected emails that look like they have to do with the microsoft exchange server running the IMAP-only account. I'll try tweaking things and maybe play around with Thunderbird to redirect...
posted by mr_roboto at 6:45 PM on February 27, 2017


« Older Minor car accident, damage to both cars, no...   |   Car Wash Undercarriage Wash Question Newer »
This thread is closed to new comments.