Skip to main content

Simple SMTP Server Demo

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smtp-server-0.0.2.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

smtp_server-0.0.2-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file smtp-server-0.0.2.tar.gz.

File metadata

  • Download URL: smtp-server-0.0.2.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for smtp-server-0.0.2.tar.gz
Algorithm Hash digest
SHA256 163190da98b990092b10554a65ea1b9f1181c663bb6e99203a3d91cc09f4810e
MD5 c7f514adeffdedf429c227a5ae5ecd72
BLAKE2b-256 e73122d5d0124d10c3e6207696509d21b70ca3bf83b7305dccd6a00b408cd9a5

See more details on using hashes here.

File details

Details for the file smtp_server-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: smtp_server-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for smtp_server-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ed6007ccf6a32535ea8a773e8c884f4437557e5879ab6fa6a3480d6066e3c4b2
MD5 00e8372df9629ee24d0fe9a0df90ba07
BLAKE2b-256 32756da69dda7e3bf65122733c685d2da26c86f40f5bb9d7f99704bbd3161bf0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page