同步并保存Gmail邮件的备份。
gmailsync的Python项目详细描述
Gmail同步
同步并保存Gmail邮件的备份
要求
- python(3.6+)
- 皮普
安装
在所有系统上,使用pip
安装gmailsync:
pip install gmailsync
更新
^{pr2}$使用
列出Gmail标签:
gmailsync -l
同步所有频道:
gmailsync
同步具体通道/组:
gmailsync group1 group2 channelXYZ
创建新的Google云项目
Gmailsync使用googleapi从Gmail检索消息。在
由于这是一个有限的服务,除非你付费,gmailsync不提供一个共同的项目,但你必须自己创建。在
对于个人或专业账户来说,免费层已经足够了。Gmailsync试图根据Google的建议来限制请求,使其不达到配额。在
要创建新的Google云平台项目,请转到此链接并创建新项目: https://console.cloud.google.com/
然后您需要为该项目启用gmailapi并生成新的oauth2.0密钥并下载它。默认情况下,gmailsync从~/.gmailsync/credentials.json
获取此文件。您可以在配置文件中自定义此路径。在
此文件将是gmailsync上下文中应用程序的凭据文件。在
配置
默认情况下,gmailsync使用这个配置文件:~/.gmailsync/config
。在
要指定其他路径,可以使用-c
选项:
gmailsync -c another/config/file ...
配置文件如下所示:
[channel-starred]mailbox:~/mail/starredquery:label:starred[channel-notifications]mailbox:~/mail/notificationsquery:label:notificationsbox_type:mbox[channel-coworkers]mailbox:~/mail/coworkersquery:from:alice@gmail.comORfrom:bob@gmail.com[group-important]channels:starred,coworkers
所以,你可以执行:
gmailsync
检索所有频道的新消息。gmailsync important
检索“started”和“cooperations”频道的新消息。gmailsync notifications
检索通道“notifications”的新消息。gmailsync important notifications
检索组“important”和通道“notifications”中通道的新消息。- 等等
配置选项按部分分组:常规、通道、组和日志。在
一般
应用程序的常规选项。在
配置文件中的节名是general
。在
选项:
Option | Description | Mandatory | Default |
---|---|---|---|
^{ | Path to the credentials file of your Google Cloud Platform project. | No | ^{ |
^{ | Path where the token file will be stored. This file contains the token for your associated Gmail account. | No | ^{ |
^{ | Default box type for all channels. | No | ^{ |
Gmailsync支持以下邮箱类型:
maildir
mbox
mh
babyl
mmdf
通道
通道的配置。在
节名称(每个通道一个)必须遵循以下模式:channel-{channnel_name}
,其中{channel_name}
必须是通道的名称。在
选项:
^{tb2}$组
组的配置。在
节名称(每个组一个)必须遵循以下模式:group-{group_name}
,其中{group}
必须是组的名称。在
选项
Option | Description | Mandatory | Default |
---|---|---|---|
^{ | List of channel names separated by comma. | Yes |
日志
记录器的配置。在
配置文件中的节名是log
。在
选项:
Option | Description | Mandatory | Default |
---|---|---|---|
^{ | Path to the file where the logs messages will be stored. | No | |
^{ | Max bytes to store in the file before rotate it. | No | 104857600 (100 MB) |
^{ | Max files to keep before to remove the oldest one. | No | 50 |
^{ | Log format for console and file logger. | No | ^{ |
完整示例
[general]credentials:/etc/gmailsync/credentials.jsontoken:/etc/gmailsync/token.picklebox_type:mbox[channel-starred]mailbox:~/mail/starredquery:label:starred[channel-notifications]mailbox:~/mail/notificationsquery:label:notificationsbox_type:maildir[channel-coworkers]mailbox:~/mail/coworkersquery:from:alice@gmail.comORfrom:bob@gmail.com[group-important]channels:starred,coworkers[log]file:/var/log/gmailsync.log
- 项目
标签: