User Tools

Site Tools


Sidebar

Public
Internal
public:it:email

This is an old revision of the document!


IMAPGrab

IMAP Sync

For syncing IMAP to IMAP only.

Dependencies

sudo apt-get install \
  libencode-imaputf7-perl \
  libfile-copy-recursive-perl \
  libio-socket-inet6-perl \
  libio-tee-perl \
  libmail-imapclient-perl \
  libunicode-string-perl \
  libsys-meminfo-perl \
  libregexp-common-perl \
  libfile-tail-perl

Offline IMAP

Install

apt

apt-get install offlineimap

Configure

  1. Create Oauth2 Credentials. You'll get a clientid and clientsecret which you'll need to put into ~/.offlineimaprc and use in the oauth2.py
  2. Clone google/gmail-oauth2-tools and use the script in python/oauth2.py.
  3. #!/bin/bash
    
    d="$HOME/Mail/gmail-oauth2-tools/python"
    
    clientid='<id>.apps.googleusercontent.com'
    clientsecret='<secrect>'
    
    ${d}/oauth2.py \
      --generate_oauth2_token \
      --client_id=${clientid} \
      --client_secret=${clientsecret}
  4. Running this script will open a web browser. Login with the gmail account you wish to sync. It will provide a Refresh and Access token. Copy both into ~/.offlineimaprc

Example ~/.offlineimaprc

Also works with a google apps account with a custom domain.

[general]
accounts = user@gmail.com

[Account user@gmail.com]
localrepository = user@gmail.com-local
remoterepository = user@gmail.com-remote

[Repository user@gmail.com-local]
type = Maildir
localfolders = ~/Mail/user@gmail.com

[Repository user@gmail.com-remote]
type = IMAP
remotehost = imap.gmail.com
remoteuser = user@gmail.com
ssl = yes
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
auth_mechanisms = XOAUTH2
oauth2_client_id = 
oauth2_client_secret = 
oauth2_access_token = 
oauth2_request_url = https://accounts.google.com/o/oauth2/token
oauth2_refresh_token = 

https://console.cloud.google.com/apis/api/gmail.googleapis.com/credentials

public/it/email.1630545092.txt.gz ยท Last modified: 2021/09/01 20:11 by admin