<p>I'm wondering what is the quickest and most reliable way to forward mail from an IMAP account.</p>

<p>My university does not allow our student-mailbox to forward to a private e-mail account (everybody uses either Gmail or Hotmail here). It's a political thing, not technical. We do have IMAP access to the mailbox. I would like to have a service which downloads the mail through IMAP, and forwards. And it would be nice to scale it, so thousands of students can use it. Eventually, I want to build a public signup page, and have it processed automatically from there. </p>

<p>So far, I've made a decent PHP script which connects, downloads headers and body parts, and ties it all together. I have two problems with that. </p>

<p>1) I'm downloading all kind of parts, and sticking them back together. I hope that every exotic attached file, weird encoded piece of text and every type of header survives this. I'm not even sure I have the complete header.</p>

<p>2) The to: e-mail address becomes the private e-mail address, not the original student e-mail address. I think this is lame, and inconvenient in searching and archiving.</p>

<p>Is the PHP script the way to go? Is there a trick using a particular linux mail service/daemon? Does IMAP have a 'forward' command, I'm missing? </p>

[{'answer_id': 57582, 'author': 'DGentry', 'author_id': 4761, 'author_profile': 'https://Stackoverflow.com/users/4761', 'pm_score': 3, 'selected': True, 'text': '<p>You might want to look at <A HREF="http://www.fetchmail.info//" rel="nofollow noreferrer">Fetchmail</A>, as this sounds like the problem it was designed to solve. Fetchmail retrieves mail from POP/IMAP/etc servers and forwards it to SMTP/LMTP/etc servers. Fetchmail has the advantage of a few years and lots of users ironing out problems with various IMAP servers.</p>\n'}, {'answer_id': 57583, 'author': 'Adam Lerman', 'author_id': 673, 'author_profile': 'https://Stackoverflow.com/users/673', 'pm_score': -1, 'selected': False, 'text': '<p>If using Gmail you can configure GMAIL to pick up mail from other accounts.</p>\n'}, {'answer_id': 57666, 'author': 'Gerrit', 'author_id': 5976, 'author_profile': 'https://Stackoverflow.com/users/5976', 'pm_score': 0, 'selected': False, 'text': "<p>Fetchmail seems like the way to go. I can use PHP to generate/edit a fetchmail command file, so that will cover the public sign-up. I'm looking for a package/script who allready does this.</p>\n\n<p>The Gmail pull only works with POP3, not with IMAP.</p>\n"}]
['https://Stackoverflow.com/questions/57547', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5976/']