oh-my-email
什么是 oh-my-email
库如其名,oh-my-email 封装常用的邮件发送功能,使得在项目中发送邮件更加方便。
支持的功能
- 简洁邮件发送API
- 支持自定义发件人昵称
- 支持抄送
- 支持HTML
- 支持附件
使用方式
安装 oh-my-email
pip install oh-my-email
from oh_my_email import (
OhMyEmail,
OhMyEmailConfig,
OhMyEmailContact,
OhMyEmailPlainContent,
OhMyEmailHtmlContent
)
from oh_my_email.vo import UrlAttachment, FileAttachment
# 初始化配置
conf = OhMyEmailConfig(
mail_host='',
mail_port=25,
mail_user='your email',
mail_pass='your password',
)
ome = OhMyEmail(conf=conf)
# 发送纯文本邮件
with ome as cl:
cl.send(
subject='test subject',
sender=OhMyEmailContact('sender email', 'sender name'),
receiver=[OhMyEmailContact('receiver email', 'receiver name')],
content=OhMyEmailPlainContent("This is a test email"),
)
# 发送带抄送人和暗抄送人纯文本邮件
with ome as cl:
cl.send(
subject='test subject',
sender=OhMyEmailContact('sender email', 'sender name'),
cc=[OhMyEmailContact('cc email', 'cc name')],
bcc=[OhMyEmailContact('bcc email', 'bcc name')],
receiver=[OhMyEmailContact('receiver email', 'receiver name')],
content=OhMyEmailPlainContent("This is a test email"),
)
# 发送HTML邮件(会将html中包含的图片链接转为base64)
with ome as cl:
img1 = "https://img9.doubanio.com/view/photo/s_ratio_poster/public/p2554525534.webp"
text = f"""
<p>Python 邮件发送测试...</p>
<p>图片演示:</p>
<p><img src="{img1}"></p>
"""
cl.send(
subject='test subject',
sender=OhMyEmailContact('sender email', 'sender name'),
receiver=[OhMyEmailContact('receiver email', 'receiver name')],
content=OhMyEmailHtmlContent(text),
)
# 发送带附件的邮件
with ome as cl:
img1 = "https://img9.doubanio.com/view/photo/s_ratio_poster/public/p2554525534.webp"
text = f"""
<p>Python 邮件发送测试...</p>
<p>图片演示:</p>
<p><img src="{img1}"></p>
"""
cl.send(
subject='test subject',
sender=OhMyEmailContact('sender email', 'sender name'),
receiver=[OhMyEmailContact('receiver email', 'receiver name')],
content=OhMyEmailHtmlContent(text),
attachment=[UrlAttachment(url='', filename=''), FileAttachment(filepath='', filename='')]
)
Metadata
Release files for oh-my-email 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| oh-my-email-0.1.0.tar.gz | 4.2 kB | Without provenance | Details for oh-my-email-0.1.0.tar.gz |
Release files / oh-my-email-0.1.0.tar.gz
| Download URL | oh-my-email-0.1.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b844d08ad9c30d7f71c6bf76c08c51f290c61239e133c315c1aab8e4af91d500
|
|
BLAKE2b-256 checksum How to use checksums |
890e1c0103b6cf67b9a97d0e0f3d7d63b1784cdb576dbefd13f641d0a21eaaca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Security for oh-my-email 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.