SMTP Server
根据 RFC 5321 实现简单的邮件服务器
安装
pip install smtp_server
启动SMTP Server
python -m smtp_sever [port]
不加port参数默认使用25端口
使用smtplib发送邮件
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
msg = MIMEMultipart('related')
msg['From'] = formataddr([""])
msg['To'] = formataddr(["", ""])
msg['Subject'] = "测试邮件"
#文本信息
txt = MIMEText('Python发送邮件测试', 'plain', 'utf-8')
msg.attach(txt)
#附件信息
# attach = MIMEApplication(open(u"X.xlsx","rb").read())
# attach.add_header('Content-Disposition', 'attachment', filename='A.xlsx')
# msg.attach(attach)
server = smtplib.SMTP('127.0.0.1', 25)
server.sendmail("faker@from-domian.com", "another-email@target-host.com", msg.as_string())
server.quit()
环境变量
PYSMTP_SERVER_DOMAIN
Metadata
Release files for smtp-server 0.0.2
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 |
|---|---|---|---|---|
| smtp-server-0.0.2.tar.gz | 16.5 kB | Without provenance | Details for smtp-server-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smtp_server-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for smtp_server-0.0.2-py3-none-any.whl |
Total release size: 33.3 kB
Release files / smtp-server-0.0.2.tar.gz
| Download URL | smtp-server-0.0.2.tar.gz |
|---|---|
| Size | 16.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
163190da98b990092b10554a65ea1b9f1181c663bb6e99203a3d91cc09f4810e
|
|
BLAKE2b-256 checksum How to use checksums |
e73122d5d0124d10c3e6207696509d21b70ca3bf83b7305dccd6a00b408cd9a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.10
|
Release files / smtp_server-0.0.2-py3-none-any.whl
| Download URL | smtp_server-0.0.2-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed6007ccf6a32535ea8a773e8c884f4437557e5879ab6fa6a3480d6066e3c4b2
|
|
BLAKE2b-256 checksum How to use checksums |
32756da69dda7e3bf65122733c685d2da26c86f40f5bb9d7f99704bbd3161bf0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.10
|
Security for smtp-server 0.0.2
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.