As of 06/26/2010, offlineimap is unmaintained.
- 1 Installing
- 2 Configuring
- 3 Usage
- 4 Miscellaneous
- 5 Troubleshooting
# pacman -S offlineimap
The example configuration that is distributed with offlineimap contains every setting and is thorougly documented.
Copy it to Template:Filename and edit it:
$ cp /usr/share/offlineimap/offlineimap.conf ~/.offlineimaprc $ vi ~/.offlineimaprc
Take care that comments are placed on their own separate line, since writing a comment after an option/value on the same line is invalid syntax.
Before running offlineimap, create any parent directories that were allocated to local repositories:
$ mkdir ~/.mail
Now, run the program:
Mail accounts will now be synced. If anything goes wrong, take a closer look at the error messages. OfflineIMAP is usually very verbose about problems; partly because the developers didn't bother with taking away tracebacks from the final product.
Various settings and improvements
Running offlineimap in the background
Most other mail transfer agents assume that the user will be using the tool as a daemon by making the program sync periodically by default. In offlineimap, there are a few settings that control backgrounded tasks.
Confusingly, they are spread thin all-over the configuration file: Template:File
1. Configure background jobs as shown in #Running offlineimap in the background.
2. Use a log-friendly user interface: Template:File
4. Finally, add a crontab entry:
$ crontab -e
The line should specify the interpreter for correct Template:Codeline results:
*/5 * * * * exec ~/bin/start_daemon -n19 -c2 -p7 python /usr/bin/offlineimap
The wrapper script is needed because offlineimap has the tendency to sporadically crash, even more so when facing connection problems.
Automatic mutt mailbox generation
Mutt cannot be simply pointed to an IMAP or maildir directory and be expected to guess which subdirectories happen to be the mailboxes, yet offlineimap can generate a muttrc fragment containing the mailboxes that it syncs. Template:File
This remote repository is configured specifically for Gmail support, substituting folder names in uppercase for lowercase, among other small additions. Keep in mind that this configuration does not sync the All Mail folder, since it is usually unnecessary and skipping it prevents bandwidth costs:
Overriding UI and autorefresh settings
For the sake of troubleshooting, it is sometimes convenient to launch offlineimap with a more verbose UI, no background syncs and perhaps even a debug level:
$ offlineimap [ -o ] [ -d <debug_type> ] [ -u <ui> ]
- Disable autorefresh, keepalive, etc.
- -d <debug_type>
- Where <debug_type> is one of Template:Codeline, Template:Codeline or Template:Codeline. Debugging imap and maildir are, by far, the most useful.
- -u <ui>
- Where <ui> is one of Template:Codeline, Template:Codeline, Template:Codeline, Template:Codeline or Template:Codeline. TTY.TTYUI is sufficient for debugging purposes.
Because of a bug in Python's ncurses package (http://bugs.python.org/issue7567) the Curses interface of OfflineIMAP breaks the terminal on exit. While it appears to irreparably lock the terminal, in reality it only prevents commands from being displayed. The bug has been fixed in Python's SVN for all versions 2.6 up to 3.2 but the current package in the repositories (Python 2.6.5) is still buggy.
In order to solve the issue:
- either append Template:Codeline to OfflineIMAP's launch command:
$ offlineimap; reset
ui = TTY.TTYUI
- or as quick workaround you can just use the following command to skip the reset() function in Curses.py which causes the problem
sudo sed -i '125i\ \ \ \ \ \ \ \ return' /usr/lib/python2.6/site-packages/offlineimap/ui/Curses.py
There are some bugs in the current Template:Package which makes it impossible to read the authentication data from Template:Filename. But they are fixed in the GIT package Template:Package AUR. Using the package you can collect all passwords in Template:Filename. And don't forget to set it's access rights:
chmod 600 ~/.netrc
An example netrc file would be Template:File
socket.ssl deprecation warnings
Depending on the currently installed python version, running offlineimap throws this warning:
DeprecationWarning: socket.ssl() is deprecated. Use ssl.wrap_socket() instead.
This can be particularly annoying when offlineimap's output is being logged or mailed through cron.
--- offlineimap/imaplibutil.py.orig 2009-08-12 01:24:23.000000000 -0430 +++ offlineimap/imaplibutil.py 2010-06-07 11:17:37.849038683 -0430 @@ -23,9 +23,11 @@ # Import the symbols we need that aren't exported by default from imaplib import IMAP4_PORT, IMAP4_SSL_PORT, InternalDate, Mon2num -# ssl is new in python 2.6 -if (sys.version_info == 2 and sys.version_info >= 6) or sys.version_info >= 3: +try: import ssl + ssl_wrap = ssl.wrap_socket +except ImportError: + ssl_wrap = socket.ssl class IMAP4_Tunnel(IMAP4): """IMAP4 client class over a tunnel @@ -169,7 +171,7 @@ if last_error != 0: # FIXME raise socket.error(last_error) - self.sslobj = socket.ssl(self.sock, self.keyfile, self.certfile) + self.sslobj = ssl_wrap(self.sock, self.keyfile, self.certfile) self.sslobj = sslwrapper(self.sslobj) mustquote = re.compile(r"[^\w!#$%&'+,.:;<=>?^`|~-]")
The diff is relative to the root buildir and it can be applied by using ABS.