Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync for gmail: copy messages from remote each time. #199

Open
moving-hawk opened this issue Jun 13, 2024 · 0 comments
Open

Sync for gmail: copy messages from remote each time. #199

moving-hawk opened this issue Jun 13, 2024 · 0 comments

Comments

@moving-hawk
Copy link

moving-hawk commented Jun 13, 2024

Each time i ran offlineimap, it would copy some messages from remote. But these messages were stored in a local dir. I am not sure why my offlineimap copy messages repeatly. I searched for a while, but don't solve it. Thank you for your help~. ( I followed archwiki for config.)

General informations

  • system/distribution (with version): Archlinux
uname -a
Linux arch 6.8.6-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Wed, 17 Apr 2024 12:20:23 +0000 x86_64 GNU/Linux
  • offlineimap version :
offlineimap -V
offlineimap v8.0.0, imaplib2 v3.06, Python v3.12.3, OpenSSL 3.3.1 4 Jun 2024
  • server name or domain: gmail
  • CLI options:
offlineimap -a gmail

Configuration file offlineimaprc

# Sample minimal config file.  Copy this to ~/.offlineimaprc and edit to
# get started fast.

[general]
pythonfile = ~/.offlineimap.py
accounts = fdu, gmail
starttls = yes
ssl = yes

[Account gmail]
localrepository = gmail-local
remoterepository = gmail-remote
autorefresh = 0.5
quick = 10
proxy = HTTP:127.0.0.1:7894
#authproxy = HTTP:127.0.0.1:7894
postsynchook = notmuch new && notifymuch


[Repository gmail-local]
type = GmailMaildir
localfolders = ~/mail/gmail

[Repository gmail-remote]
type = Gmail
ipv6 = False
remoteuser = ***@gmail.com
#remotepasseval = get_pass("gmail")
nametrans = lambda foldername: re.sub ('sent_mail', 'sent',
                               re.sub ('starred', 'flagged',
                               re.sub (' ', '_', foldername.lower())))
folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail']
# Necessary as of OfflineIMAP 6.5.4
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
# Necessary to work around https://github.com/OfflineIMAP/offlineimap/issues/573 (versions 7.0.12, 7.2.1)
ssl_version = tls1_2
keepalive = 60
holdconnectionopen = yes
auth_mechanisms = XOAUTH2
oauth2_client_id = 
oauth2_client_secret = 
oauth2_request_url = https://accounts.google.com/o/oauth2/token
oauth2_access_token_eval = get_token("****@gmail.com")

pythonfile (if any)

cat .offlineimap.py 
#! /usr/bin/env python
from subprocess import check_output
from subprocess import run
import os

os.environ["http_proxy"] = "http://127.0.0.1:7894"
os.environ["https_proxy"] = "http://127.0.0.1:7894"

def get_pass(account):
    return check_output("pass Mail/" + account, shell=True).splitlines()[0]

def get_token(email_address):
    run(["oama", "renew", email_address], env=os.environ)
    return run(["oama", "access", email_address], capture_output=True, text=True, env=os.environ).stdout

Logs

OfflineIMAP 8.0.0
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v3.06, Python v3.12.3, OpenSSL 3.3.1 4 Jun 2024
Obtained new access token for [email protected] - expires at 2024-06-13 09:08 UTC.
Account sync gmail:
 *** Processing account gmail
 Establishing connection to imap.gmail.com:993 (gmail-remote)
 Creating folder inbox[gmail-remote]
 Creating new Local Status db for gmail-local:inbox
Folder [gmail] [acc: gmail]:
 Syncing [gmail]: Gmail -> GmailMaildir
Folder [gmail]/drafts [remote name [Gmail]/Drafts] [acc: gmail]:
 Syncing [Gmail]/Drafts: Gmail -> GmailMaildir
Folder [gmail]/drafts [acc: gmail]:
 Syncing [gmail]/drafts: Gmail -> GmailMaildir
Folder [gmail]/flagged [remote name [Gmail]/Starred] [acc: gmail]:
 Syncing [Gmail]/Starred: Gmail -> GmailMaildir
Folder [gmail]/flagged [acc: gmail]:
 Syncing [gmail]/flagged: Gmail -> GmailMaildir
Folder [gmail]/important [remote name [Gmail]/Important] [acc: gmail]:
 Syncing [Gmail]/Important: Gmail -> GmailMaildir
Folder [gmail]/flagged [acc: gmail]:
 Deleting 8 messages (1:5,8:10) in GmailMaildir[[gmail].flagged]
Folder [gmail]/important [remote name [Gmail]/Important] [acc: gmail]:
 Copy message UID 27 (1/185) gmail-remote:[Gmail]/Important -> gmail-local:[gmail].important
 Copy message UID 52 (2/185) gmail-remote:[Gmail]/Important -> gmail-local:[gmail].important
 Copy message UID 53 (3/185) gmail-remote:[Gmail]/Important -> gmail-local:[gmail].important
 Copy message UID 57 (4/185) gmail-remote:[Gmail]/Important -> gmail-local:[gmail].important
...
 Copy message UID 323 (179/185) gmail-remote:[Gmail]/Important -> gmail-local:[gmail].important
 Copy message UID 324 (180/185) gmail-remote:[Gmail]/Important -> gmail-local:[gmail].important
 Copy message UID 325 (181/185) gmail-remote:[Gmail]/Important -> gmail-local:[gmail].important
 Copy message UID 326 (182/185) gmail-remote:[Gmail]/Important -> gmail-local:[gmail].important
 Copy message UID 327 (183/185) gmail-remote:[Gmail]/Important -> gmail-local:[gmail].important
 Copy message UID 328 (184/185) gmail-remote:[Gmail]/Important -> gmail-local:[gmail].important
 Copy message UID 329 (185/185) gmail-remote:[Gmail]/Important -> gmail-local:[gmail].important
Folder [gmail]/sent [remote name [Gmail]/Sent Mail] [acc: gmail]:
 Syncing [Gmail]/Sent Mail: Gmail -> GmailMaildir
Folder [gmail]/important [acc: gmail]:
 Syncing [gmail]/important: Gmail -> GmailMaildir
 Deleting 195 messages (1:2,6,9:13,16:17,27,52:53,57:60,62:74,77:85,88:93,96:115,117:123,125:130,134,136:137,139:143,145,148:153,156,158:163,166:176,206,247:329) in GmailMaildir[[gmail].important]
Folder [gmail]/sent [remote name [Gmail]/Sent Mail] [acc: gmail]:
 Copy message UID 1 (1/37) gmail-remote:[Gmail]/Sent Mail -> gmail-local:[gmail].sent
 Copy message UID 2 (2/37) gmail-remote:[Gmail]/Sent Mail -> gmail-local:[gmail].sent
 Copy message UID 3 (3/37) gmail-remote:[Gmail]/Sent Mail -> gmail-local:[gmail].sent
 Copy message UID 4 (4/37) gmail-remote:[Gmail]/Sent Mail -> gmail-local:[gmail].sent
 Copy message UID 5 (5/37) gmail-remote:[Gmail]/Sent Mail -> gmail-local:[gmail].sent
 Copy message UID 6 (6/37) gmail-remote:[Gmail]/Sent Mail -> gmail-local:[gmail].sent
...
 Copy message UID 35 (34/37) gmail-remote:[Gmail]/Sent Mail -> gmail-local:[gmail].sent
 Copy message UID 36 (35/37) gmail-remote:[Gmail]/Sent Mail -> gmail-local:[gmail].sent
 Copy message UID 37 (36/37) gmail-remote:[Gmail]/Sent Mail -> gmail-local:[gmail].sent
 Copy message UID 38 (37/37) gmail-remote:[Gmail]/Sent Mail -> gmail-local:[gmail].sent
Folder [gmail]/sent [acc: gmail]:
 Syncing [gmail]/sent: Gmail -> GmailMaildir
Folder [gmail]/spam [remote name [Gmail]/Spam] [acc: gmail]:
 Syncing [Gmail]/Spam: Gmail -> GmailMaildir
Folder [gmail]/sent [acc: gmail]:
 Deleting 37 messages (1:29,31:38) in GmailMaildir[[gmail].sent]
Folder [gmail]/spam [remote name [Gmail]/Spam] [acc: gmail]:
 Copy message UID 342 (1/11) gmail-remote:[Gmail]/Spam -> gmail-local:[gmail].spam
 Copy message UID 343 (2/11) gmail-remote:[Gmail]/Spam -> gmail-local:[gmail].spam
 Copy message UID 344 (3/11) gmail-remote:[Gmail]/Spam -> gmail-local:[gmail].spam
 Copy message UID 345 (4/11) gmail-remote:[Gmail]/Spam -> gmail-local:[gmail].spam
 Copy message UID 346 (5/11) gmail-remote:[Gmail]/Spam -> gmail-local:[gmail].spam
 Copy message UID 347 (6/11) gmail-remote:[Gmail]/Spam -> gmail-local:[gmail].spam
 Copy message UID 348 (7/11) gmail-remote:[Gmail]/Spam -> gmail-local:[gmail].spam
 Copy message UID 349 (8/11) gmail-remote:[Gmail]/Spam -> gmail-local:[gmail].spam
 Copy message UID 350 (9/11) gmail-remote:[Gmail]/Spam -> gmail-local:[gmail].spam
 Copy message UID 351 (10/11) gmail-remote:[Gmail]/Spam -> gmail-local:[gmail].spam
 Copy message UID 352 (11/11) gmail-remote:[Gmail]/Spam -> gmail-local:[gmail].spam
Folder [gmail]/spam [acc: gmail]:
 Syncing [gmail]/spam: Gmail -> GmailMaildir
Folder [gmail]/trash [remote name [Gmail]/Trash] [acc: gmail]:
 Syncing [Gmail]/Trash: Gmail -> GmailMaildir
Folder [gmail]/spam [acc: gmail]:
 Deleting 11 messages (342:352) in GmailMaildir[[gmail].spam]
Folder inbox [remote name INBOX] [acc: gmail]:
 Syncing INBOX: Gmail -> GmailMaildir
Folder [gmail]/trash [acc: gmail]:
 Syncing [gmail]/trash: Gmail -> GmailMaildir
Account sync gmail:
 Calling hook: notmuch new && notifymuch
 Hook stdout: No new mail. Removed 7 messages.

Hook stderr:

 Hook return code: 0
 *** Finished account 'gmail' in 4:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant