# ForMaiR **Repository Path**: k8scat/ForMaiR ## Basic Information - **Project Name**: ForMaiR - **Description**: auto Forward eMails with custom Rules 自定义规则的邮件自动转发工具 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: https://formair.io - **GVP Project**: No ## Statistics - **Stars**: 6 - **Forks**: 2 - **Created**: 2021-02-07 - **Last Updated**: 2025-04-09 ## Categories & Tags **Categories**: networklib **Tags**: None ## README # [ForMaiR](https://formair.io) - auto Forward eMails with custom Rules

CodeFactor

GitHub | 码云

自定义规则的邮件自动转发工具。 ## 使用 Docker 快速开始 参考配置:[template/config.yaml](https://github.com/k8scat/ForMaiR/blob/master/template/config.yaml) ```bash docker run -d --rm \ -v /path/to/config.yaml:/formair/conf/config.yaml \ k8scat/formair:latest ``` ## 安装 ### 使用 `pip` ```bash python3 -m pip install --user formair ``` ### 使用 `git` ```bash git clone git@github.com:k8scat/ForMaiR.git cd ForMaiR python3 setup.py install ``` ## 使用 参考配置:[template/config.yaml](https://github.com/k8scat/ForMaiR/blob/master/template/config.yaml) ```bash formair # 从 ./config.yaml 中加载配置 formair /path/to/config.yaml # 从 /path/to/config.yaml 中加载配置 ``` ## 自定义规则 满足下列任一规则的邮件会被转发到指定的邮箱列表(`to_addrs`) - [x] 邮件的发件人(`from_addr[1]`)在指定的发件人列表中(`from_addrs`) - [x] 邮件的主题(`subject`)匹配指定的主题正则表达式(`subject_pattern`) - [x] 邮件的内容(`plain_content` 或 `html_content`)匹配指定的内容正则表达式(`content_pattern`) ```yaml rules: - to_addrs: - 't1@example.com' - 't2@example.com' from_addrs: - 'f1@example.com' - 'f2@example.com' subject_pattern: '' content_pattern: '' - to_addrs: - 't1@example.com' - 't2@example.com' from_addrs: - 'f1@example.com' - 'f2@example.com' subject_pattern: '' content_pattern: '' ``` ## 只转发新邮件 支持转发指定范围内的新邮件。 - 从 _index_file_ 文件中获取上次读取的邮件位置(`last_email_index`) (如果文件不存在,则默认是 0) - 从 `pop3_server.stat` 获取当前邮件的总数(`email_count`) ```python for index in range(last_email_index+1, email_count+1): pass ``` ## 文档 [https://formair.io](https://formair.io)