一个简单易用的邮件客户端,支持发送和接收邮件,支持 QQ 邮箱、163邮箱等邮箱
Project description
emailclient
一个简单易用的邮件客户端,支持发送和接收邮件,可以处理附件、设置过滤条件等功能。支持 QQ 邮箱、163邮箱等邮箱
支持的邮箱
- QQ邮箱
- 163邮箱(网易邮箱)
- 139邮箱
- iCloud
- Gmail
- Outlook/Hotmail
安装
pip install emlclient
使用示例
1. 读取未读邮件
from emlclient import EmailClient
# 初始化邮件客户端
client = EmailClient(
username="your_email@example.com",
password="your_password"
)
# 读取最新的3封未读邮件
emails = client.read_emails(
criteria="UNSEEN",
limit=3,
seen=True # 设置为已读
)
# 打印邮件内容
for email in emails:
print(f"发件人: {email['sender']}")
print(f"主题: {email['subject']}")
print(f"内容: {email['body']}\n")
2. 发送带附件的邮件
from emlclient import EmailClient
client = EmailClient(
username="your_email@example.com",
password="your_password"
)
# 发送带附件的邮件
result = client.send_email(
to="recipient@example.com",
subject="测试邮件",
content="这是一封测试邮件",
attachments=["document.pdf", "image.jpg"]
)
3. 按条件搜索邮件
from emlclient import EmailClient
client = EmailClient(
username="your_email@example.com",
password="your_password"
)
# 搜索2024年1月1日之后的包含"发票"的邮件
emails = client.read_emails(
criteria='SINCE "01-Jan-2024" SUBJECT "发票"',
limit=5
)
# 打印搜索结果
for email in emails:
print(f"日期: {email['date']}")
print(f"主题: {email['subject']}")
搜索条件说明
支持的搜索条件包括:
ALL: 所有邮件UNSEEN: 未读邮件SEEN: 已读邮件FROM "someone@example.com": 来自特定发件人的邮件TO "someone@example.com": 发送给特定收件人的邮件SUBJECT "test": 主题包含特定文字的邮件SINCE "01-Jan-2020": 某个日期之后的邮件BEFORE "01-Jan-2020": 某个日期之前的邮件LARGER 1000: 大于1000字节的邮件SMALLER 1000: 小于1000字节的邮件
多个条件可以组合使用,如: UNSEEN SUBJECT "test"
注意事项
- 部分邮箱服务商可能需要特殊配置,请参考各自的文档(比如一些邮箱密码需要使用授权码而不是登录密码)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
emlclient-1.0.0.tar.gz
(5.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file emlclient-1.0.0.tar.gz.
File metadata
- Download URL: emlclient-1.0.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67fb18c3d877535885e76241c99fd0dce554bfd1c26429452a0c4565f101ed96
|
|
| MD5 |
dd4bea3bf2bedff833a3978a804e31f5
|
|
| BLAKE2b-256 |
f7af164876511353baee89ae3a3f31b58e8e0cf47f865526cfc6e26e88f3641b
|
File details
Details for the file emlclient-1.0.0-py3-none-any.whl.
File metadata
- Download URL: emlclient-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a733b077dc4b3c4b256e370ae85843ebfe6d85ea303ca6a4cf97731f324a368b
|
|
| MD5 |
20031d54767510eab45334412efc6cee
|
|
| BLAKE2b-256 |
e31e66a1f07f65d53caaf52eaba566128b874718e3275d3812cd147aadc539fc
|