<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Erics Tech Blog &#187; imap</title>
	<atom:link href="http://eric.lubow.org/tag/imap/feed/" rel="self" type="application/rss+xml" />
	<link>http://eric.lubow.org</link>
	<description>Thoughts, musings, and other idealistic (sometimes useful) systems and development hoopla.</description>
	<lastBuildDate>Fri, 18 Nov 2011 14:56:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Transferring Email From Gmail/Google Apps to Dovecot With Larch</title>
		<link>http://eric.lubow.org/2009/mail/transferring-email-from-gmailgoogle-apps-to-dovecot-with-larch/</link>
		<comments>http://eric.lubow.org/2009/mail/transferring-email-from-gmailgoogle-apps-to-dovecot-with-larch/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 12:15:56 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Mail]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://eric.lubow.org/?p=458</guid>
		<description><![CDATA[As regular readers of this blog know, I am in the process of trying to back up Google Apps accounts to Dovecot. Well I have finally found my solution. Not only does it work, but its in Ruby. First thing that you&#8217;ll need to do is grab yourself a copy of Larch. I did this [...]]]></description>
			<content:encoded><![CDATA[<p>As regular readers of this blog know, I am in the process of trying to back up <a href="http://eric.lubow.org/2009/mail/backing-up-gmailgoogle-apps-to-a-dovecot-server/">Google Apps accounts to Dovecot</a>.  Well I have finally found my solution.  Not only does it work, but its in Ruby.</p>
<p>First thing that you&#8217;ll need to do is grab yourself a copy of <a href="http://github.com/rgrove/larch">Larch</a>.  I did this simply by typing and it installed everything nicely, but click the link to the repository on Github if it doesn&#8217;t work for you.<br />
<span id="more-458"></span></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ sudo gem install larch</div></div>
<p>Immediately I dove in and ran it.  And immediately I hit my first problem:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ larch --from imaps://imap.gmail.com --from-user user@gmail.com --from-pass FILTERED --to-pass me@myserver.com --to-pass FILTERED --all<br />
... Removed for brevity ...<br />
NameError: uninitialized constant Larch::IMAP::OpenSSL (cannot recover)</div></div>
<p>The fix for this issue is that SSL needs to be available (or installed as a library) to Ruby.  Since I have Ruby built from source, it was just as easy as what&#8217;s below.  I have removed the output for readability.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ cd /usr/local/src/ruby-1.8.6/ext/openssl<br />
$ ruby extconf.rb<br />
$ make<br />
$ sudo make install</div></div>
<p>Now that we have SSL installed, let&#8217;s try it again.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[Dec 07 16:54:06] [info] user1@googleappsdomain.com@mail.mydomain.com: Net::IMAP::NoResponseError: Mailbox doesn't allow inferior mailboxes (will retry)<br />
[Dec 07 16:54:09] [fatal] Net::IMAP::NoResponseError: Mailbox doesn't allow inferior mailboxes (giving up)<br />
[Dec 07 16:54:09] [info] 69 message(s) copied, 0 failed, 0 untouched out of 69 total</div></div>
<p>Whoops, another stopping point.  If you are receiving the above error, then you need to make sure that your dovecot installation is set up for maildir.  What this error is saying is that your installation doesn&#8217;t support folder that are folders and mailboxes at the same time.  If your current dovecot installation is setup for mbox, you will need to convert it.  That is beyond the scope of this post, but add the code below in the <strong>/etc/dovecot.conf</strong> if it&#8217;s not already there.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mail_location = maildir:/var/spool/mail/vhosts/%d/%u/Maildir<br />
namespace private {<br />
separator = /<br />
prefix = &quot;&quot;<br />
inbox = yes<br />
}</div></div>
<p>I have been happily and successfully running Larch ever since.  </p>


<p>Related posts:<ol><li><a href='http://eric.lubow.org/2009/mail/backing-up-gmailgoogle-apps-to-a-dovecot-server/' rel='bookmark' title='Backing Up Gmail/Google Apps to a Dovecot Server'>Backing Up Gmail/Google Apps to a Dovecot Server</a></li>
<li><a href='http://eric.lubow.org/2007/perl/mailimapclient/' rel='bookmark' title='Mail::IMAPClient'>Mail::IMAPClient</a></li>
<li><a href='http://eric.lubow.org/2007/perl/emailfind/' rel='bookmark' title='Email::Find'>Email::Find</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://eric.lubow.org/2009/mail/transferring-email-from-gmailgoogle-apps-to-dovecot-with-larch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backing Up Gmail/Google Apps to a Dovecot Server</title>
		<link>http://eric.lubow.org/2009/mail/backing-up-gmailgoogle-apps-to-a-dovecot-server/</link>
		<comments>http://eric.lubow.org/2009/mail/backing-up-gmailgoogle-apps-to-a-dovecot-server/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 11:00:48 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Mail]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[imap]]></category>

		<guid isPermaLink="false">http://eric.lubow.org/?p=446</guid>
		<description><![CDATA[I have been trying to find a way to copy everything from a Gmail account to a Dovecot mail server. The way I have ended up doing it so far is simply by using Apple Mail (if you regularly read this blog, you&#8217;d know that I use a Mac). The steps are as follows: Create [...]]]></description>
			<content:encoded><![CDATA[<p>I have been trying to find a way to copy everything from a Gmail account to a Dovecot mail server.  The way I have ended up doing it so far is simply by using Apple Mail (if you regularly read this blog, you&#8217;d know that I use a Mac).  The steps are as follows:</p>
<ol>
<li>Create 2 accounts in Apple Mail: Gmail and the Dovecot account</li>
<li>Sync the Gmail account to your local computer</li>
<li>Copy everything to the Dovecot server</li>
</ol>
<p>This works, but I have to use a slow connection (my home connection) and I have a lot of accounts to do this for, so I would much prefer to script this.  The problem is that I have been trying to get this to work with either <a href="http://freshmeat.net/projects/imapsync/">imapsync</a> or <a href="http://code.google.com/p/imapcopy/">imapcopy</a>.  Neither seem to work properly.<br />
<span id="more-446"></span><br />
According to the documentation, I have the proper version and it should work with GMail.  I tried all the supported <strong>&#8211;authmech1</strong> possibilities.  I found an article saying that Google doesn&#8217;t accept the word <em>AUTHENTICATE</em> when authenticating, but then imapsync wouldn&#8217;t work and it claims it does.  So, when trying imapsync, this is what it looked like (some of the security issues have been blocked to protect the innocent):</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[root@smtp4 imapsync-1.286]# ./imapsync --host1 imap.gmail.com --ssl1 --user1 user1@gmail.com --password1 MASKED --host2 mail.server.com --user2 user1@server.com --password2 MASKED<br />
$RCSfile: imapsync,v $ $Revision: 1.286 $ $Date: 2009/07/24 15:53:04 $ <br />
Here is a [linux] system (Linux mail.server.com 2.6.18-92.1.18.el5xen #1 SMP Wed Nov 12 09:48:10 EST 2008 x86_64)<br />
with perl 5.8.8<br />
Mail::IMAPClient &nbsp;3.21<br />
IO::Socket &nbsp; &nbsp; &nbsp; &nbsp;1.31<br />
IO::Socket::SSL &nbsp; <br />
Digest::MD5 &nbsp; &nbsp; &nbsp; 2.36<br />
Digest::HMAC_MD5 &nbsp;<br />
Term::ReadKey &nbsp; &nbsp; <br />
Date::Manip &nbsp; &nbsp; &nbsp; <br />
&nbsp;and the module Mail::IMAPClient version used here is 3.21<br />
Command line used:<br />
./imapsync --host1 imap.gmail.com --ssl1 --user1 user1@gmail.com --password1 MASKED --host2 mail.server.com --user2 user1@server.com --password2 MASKED --useheader Message-Id --skipsize --regextrans2 s/\[Gmail\]/Gmail/</div></div>
<p>My attempt at imapcopy was closer to successful, but still not what I needed.  I ran into some Dovecot errors (at least I think that&#8217;s what it is) that I am not sure what to do with.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[root@smtp4 imapCopy]# time sh imapCopy.sh imaps://user1%40gmail.com:MASKED@imap.gmail.com imap://user1%40server.com:MASKED@mail.server.com<br />
2009-12-02 18:13:28,811 &nbsp;INFO ImapCopier - Starting<br />
2009-12-02 18:13:28,812 DEBUG ImapCopier - Parameters length:2<br />
2009-12-02 18:13:28,813 DEBUG ImapCopier - opening conections<br />
2009-12-02 18:13:28,816 DEBUG ImapCopier - opening imaps conection to imap.gmail.com<br />
2009-12-02 18:13:32,633 DEBUG ImapCopier - opening imap conection to mail.server.com<br />
2009-12-02 18:13:34,666 DEBUG ImapCopier - Creating target Folder: Adbrite<br />
Exception in thread &quot;main&quot; javax.mail.MessagingException: Unsupported type;<br />
&nbsp; nested exception is:<br />
&nbsp; &nbsp; &nbsp; &nbsp; com.sun.mail.iap.ProtocolException: Unsupported type<br />
&nbsp; &nbsp; &nbsp; &nbsp; at com.sun.mail.imap.IMAPFolder.doCommandIgnoreFailure(IMAPFolder.java:2618)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at com.sun.mail.imap.IMAPFolder.create(IMAPFolder.java:725)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at com.fisbein.joan.model.ImapCopier.copyFolderAndMessages(ImapCopier.java:190)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at com.fisbein.joan.model.ImapCopier.copy(ImapCopier.java:152)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at com.fisbein.joan.model.ImapCopier.main(ImapCopier.java:35)<br />
Caused by: com.sun.mail.iap.ProtocolException: Unsupported type<br />
&nbsp; &nbsp; &nbsp; &nbsp; at com.sun.mail.imap.IMAPFolder$6.doCommand(IMAPFolder.java:745)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at com.sun.mail.imap.IMAPFolder.doProtocolCommand(IMAPFolder.java:2639)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at com.sun.mail.imap.IMAPFolder.doCommandIgnoreFailure(IMAPFolder.java:2611)<br />
&nbsp; &nbsp; &nbsp; &nbsp; ... 4 more</div></div>
<p>So if you have any idea what to do here in a more intelligent manner than I am stuck with, please let me know in the comments.  Thanks.</p>


<p>Related posts:<ol><li><a href='http://eric.lubow.org/2009/mail/transferring-email-from-gmailgoogle-apps-to-dovecot-with-larch/' rel='bookmark' title='Transferring Email From Gmail/Google Apps to Dovecot With Larch'>Transferring Email From Gmail/Google Apps to Dovecot With Larch</a></li>
<li><a href='http://eric.lubow.org/2007/perl/mailimapclient/' rel='bookmark' title='Mail::IMAPClient'>Mail::IMAPClient</a></li>
<li><a href='http://eric.lubow.org/2009/system-administration/creating-a-slave-dns-server-on-bind9/' rel='bookmark' title='Creating a Slave DNS Server on Bind9'>Creating a Slave DNS Server on Bind9</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://eric.lubow.org/2009/mail/backing-up-gmailgoogle-apps-to-a-dovecot-server/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

