同步并保存Gmail邮件的备份。

gmailsync的Python项目详细描述


Gmail同步

Build Status

同步并保存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。在

选项:

OptionDescriptionMandatoryDefault
^{}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}必须是组的名称。在

选项

OptionDescriptionMandatoryDefault
^{}List of channel names separated by comma.Yes

日志

记录器的配置。在

配置文件中的节名是log。在

选项:

OptionDescriptionMandatoryDefault
^{}Path to the file where the logs messages will be stored.No
^{}Max bytes to store in the file before rotate it.No104857600 (100 MB)
^{}Max files to keep before to remove the oldest one.No50
^{}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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
jframe为什么JAVA paint()方法不起作用?   java Guice:将ContainerRequestContext注入拦截器   java如何优雅地关闭Spring JMS MessageListenerAdapter   java如何在Spring中设置快照隔离级别   Java中的安卓平台独立信任存储路径   java无法在eclipse中运行hello world程序   java Sinch空指针问题   使用Java将JSON流式传输到BigQuery   java从“大数据”中选择什么Swing控件?   java通过对象字段过滤/排序集合?   java将数据从活动传递到另一个活动中的片段   java访问打包在jar文件中的文档   Java获取事件的大小。getDragboard()。getFiles()。流()。映射(文件::长度)。toString());   java Android libgdx:启动程序图标按下后,启动屏幕不会立即显示   java如何在Google App Engine灵活环境中配置oracle jdk   java有没有办法减少这些行?   Java:客户端socket不读取第二行,在终止符行之后保持打开状态   java以编程方式获取api 29上的所有APK文件   java ActionBar按钮不显示