🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

smtp-server

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smtp-server

Simple SMTP Server Demo

0.0.2
100

Supply Chain Security

100

Vulnerability

99

Quality

100

Maintenance

70

License

Unpopular package

Quality

This package is not very popular.

Found 1 instance in 1 package

Network access

Supply chain risk

This module accesses the network.

Found 1 instance in 1 package

Maintainers
1

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

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts