Simple Email Sender using Python 3.

Related tags

Emailemail-sender
Overview

Email Sender

使用 Python 3 实现的简单邮件发送工具。

Version: 0.1.2 (Beta)

主要功能

  • 使用 SMTP 协议发送邮件
  • 支持 SSL/TLS 、 STARTTLS 加密(为保证安全,强制加密发送)
  • 支持邮件模板与邮件生成
  • 支持向多人群发邮件
  • 日志记录
  • 脚本执行
  • 多线程发送邮件

邮件模板介绍

使用HTML格式编写模板,遵循如下正则表达式实现文本替换:

\{\s*%\s*(label)\s*%\s*\}

例如:

{% name %}

其中,label 为定位用于替换的标签,遵守 Python 变量名命名规则,且不为 receiver, subject, receiver_name, attachments, email_id 中的任意一个, 如例子中的 name

替换内容位于配置文件的 receivers.replace 和 template.global.replace 中, 可以分别设置每位接收者的替换信息和全局的替换信息。

当提供了不存在的 label 会被忽略,当模板中的标签没有可替换的项时会原样输出。

当发生替换时,整个标签都会被替换,如 {% name %},你好name=Holger 时会替换为 Holger,你好

template 目录中提供了一个模板可供参考。

配置文件介绍

使用 Yaml 作为配置文件,其具体格式如下:

mail:  # 发件方信息
  host: smtp.example.com  # smtp 服务器,请询问邮件服务提供商
  port: 587  # smtp 发送端口,请询问邮件服务提供商
  starttls: true  # 是否开启 starttls,默认为 false
  user: [email protected]  # 发送方 Email
  passwd: password  # 发送方密码或授权码
  name: Your name  # 可选,发送方名字
template:  # 邮件模板信息
  use_file: true  # 是否提供一个 html 文件作为模板
  file: /path/to/template/filename.html
  # 当 use_file=false, 须提供 content 作为模板的内容
  global:  # 全局配置,可选(每一项都可选),下方接收者的配置会将其覆盖
    subject: For Test  # 邮件主题,和下方的至少一个不为空
    attachments: []  # 附件文件路径列表
    replace:  # 替换内容 格式为 `label: 替换的文本` 下同
      message: This is a test email.
receivers:  # 接收者信息,为 yaml 数组
  -
    email: [email protected]  # 接收者 Email
    name: User  # 可选,接收者名字
    subject: For Test, Email Sender  # 邮件主题,和上方的至少一个不为空
    attachments: []  # 可选,附件文件路径列表
    replace:  # 替换内容 格式为 `label: 替换的文本`
      name: User

(计划内)测试的(发送)邮箱:

由于精力有限,欢迎提供不在列表内的其他邮箱测试!

  • Outlook
    • host: smtp.office365.com
    • port: 587
    • starttls: true
  • QQ Mail / foxmail.com
    • host: smtp.qq.com
    • port: 587 (starttls: true) 或 465 (starttls: false)
    • passwd: 填写授权码,请参考官方文档
  • 163 Mail
    • host: smtp.163.com

      126,yeah.net 邮箱请自行更换服务器地址中相关参数。例如 smtp.126.com 和 smtp.yeah.net

    • port: 465
    • starttls: false
    • passwd: 填写授权码,请参考官方文档
  • Gmail (需要更多测试)
    • host: smtp.gmail.com
    • port: 587 (starttls: true) 或 465 (starttls: false)

    需要能够正常访问 Gmail 的网络环境。若无法登录,请参考官方文档

  • SUDA 学生邮箱 stu.suda.edu.cn (使用该邮箱发送的邮件可能被认为是垃圾邮件)
    • host: smtp.stu.suda.edu.cn
    • port: 465
    • starttls: false

运行方法

  1. 从控制台运行:

    运行 console-tool.py 或者下载二进制文件,默认读取运行目录下的 config.ini 文件;可以指定 -c/--config 参数给出 Yaml 配置文件路径。

  2. 作为 package 附加于其他项目运行:

    参考 console-tool.py 的代码。实际上,可以将配置项存储为字典,调用 Poster.sender.send_email 并传入配置项即可。

Q&A

  • 遇到错误:SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful ...').

    请检查邮箱是否能够正常登录。

  • 遇到错误:SMTPServerDisconnected: Connection unexpectedly closed

    请检查端口是否有误。

You might also like...
GMailBomber is a form of Internet abuse which is perpetrated through the sending of massive volumes of email to a specific email address with the goal of overflowing the mailbox and overwhelming the mail server hosting the address, making it into some form of denial of service attack.

GMailBomber is a form of Internet abuse which is perpetrated through the sending of massive volumes of email to a specific email address with the goal of overflowing the mailbox and overwhelming the mail server hosting the address, making it into some form of denial of service attack.

Email-osint - Email OSINT tool written in python3
Email-osint - Email OSINT tool written in python3

Email-osint - Email OSINT tool written in python3

Simple, powerfull and nonobstructive django email middleware.

djmail djmail is a BSD Licensed, simple and nonobstructive django email middleware. Why use djmail? Because it: Sends emails asynchronously without ad

A simple library project, a library function to make a temporary email, receive all messages
A simple library project, a library function to make a temporary email, receive all messages

fake-email A simple library project, a library function to make a temporary email, receive all messages Installation : pip install fake-email Example

Spam-bot - Simple email-spammer discord bot

📝 Functional [ ✔️ ] Premium system via .json [ ✔️ ] Spammer [ ✔️ ] Validater [ ✔️ ] Discord bot ❓ How to launch ➡️ 1) Make discord bot ➡️ 2) Paste to

Send email in Python conveniently for gmail using yagmail
Send email in Python conveniently for gmail using yagmail

yagmail -- Yet Another GMAIL/SMTP client For the asynchronous asyncio version, look here: https://github.com/kootenpv/aioyagmail The goal here is to m

Command line interface for sending email using SMTP (ships with Gmail configuration).

mailsend Description Lightweight command line interface for sending email using SMTP. Default configuration is set for Gmail (smtp.gmail.com at port 5

Python email address and Mime parsing library

Flanker - email address and MIME parsing for Python Flanker is an open source parsing library written in Python by the Mailgun Team. Flanker currently

Disposable Temporary Email (Python Library)

Disposable Temporary Email (Python Library)

Releases(v0.1.2)
  • v0.1.2(Feb 13, 2022)

    Version: 0.1.2 (Beta)

    主要功能

    • 使用 SMTP 协议发送邮件
    • 支持 SSL/TLS 、 STARTTLS 加密(为保证安全,强制加密发送)
    • 支持邮件模板与邮件生成
    • 支持向多人群发邮件
    • 日志记录
    • 脚本执行
    • 多线程发送邮件

    邮件模板介绍

    使用HTML格式编写模板,遵循如下正则表达式实现文本替换:

    \{\s*%\s*(label)\s*%\s*\}
    

    例如:

    {% name %}
    

    其中,label 为定位用于替换的标签,遵守 Python 变量名命名规则,且不为 receiver, subject, receiver_name, attachments, email_id 中的任意一个, 如例子中的 name

    替换内容位于配置文件的 receivers.replace 和 template.global.replace 中, 可以分别设置每位接收者的替换信息和全局的替换信息。

    当提供了不存在的 label 会被忽略,当模板中的标签没有可替换的项时会原样输出。

    当发生替换时,整个标签都会被替换,如 {% name %},你好name=Holger 时会替换为 Holger,你好

    template 目录中提供了一个模板可供参考。

    配置文件介绍

    使用 Yaml 作为配置文件,其具体格式如下:

    mail:  # 发件方信息
      host: smtp.example.com  # smtp 服务器,请询问邮件服务提供商
      port: 587  # smtp 发送端口,请询问邮件服务提供商
      starttls: true  # 是否开启 starttls,默认为 false
      user: [email protected]  # 发送方 Email
      passwd: password  # 发送方密码或授权码
      name: Your name  # 可选,发送方名字
    template:  # 邮件模板信息
      use_file: true  # 是否提供一个 html 文件作为模板
      file: /path/to/template/filename.html
      # 当 use_file=false, 须提供 content 作为模板的内容
      global:  # 全局配置,可选(每一项都可选),下方接收者的配置会将其覆盖
        subject: For Test  # 邮件主题,和下方的至少一个不为空
        attachments: []  # 附件文件路径列表
        replace:  # 替换内容 格式为 `label: 替换的文本` 下同
          message: This is a test email.
    receivers:  # 接收者信息,为 yaml 数组
      -
        email: [email protected]  # 接收者 Email
        name: User  # 可选,接收者名字
        subject: For Test, Email Sender  # 邮件主题,和上方的至少一个不为空
        attachments: []  # 可选,附件文件路径列表
        replace:  # 替换内容 格式为 `label: 替换的文本`
          name: User
    

    (计划内)测试的(发送)邮箱:

    由于精力有限,欢迎提供不在列表内的其他邮箱测试!

    • [x] Outlook
      • host: smtp.office365.com
      • port: 587
      • starttls: true
    • [x] QQ Mail / foxmail.com
      • host: smtp.qq.com
      • port: 587 (starttls: true) 或 465 (starttls: false)
      • passwd: 填写授权码,请参考官方文档
    • [x] 163 Mail
      • host: smtp.163.com

        126,yeah.net 邮箱请自行更换服务器地址中相关参数。例如 smtp.126.com 和 smtp.yeah.net

      • port: 465
      • starttls: false
      • passwd: 填写授权码,请参考官方文档
    • [ ] Gmail (需要更多测试)
      • host: smtp.gmail.com
      • port: 587 (starttls: true) 或 465 (starttls: false)

      需要能够正常访问 Gmail 的网络环境。若无法登录,请参考官方文档

    • [x] SUDA 学生邮箱 stu.suda.edu.cn (使用该邮箱发送的邮件可能被认为是垃圾邮件)
      • host: smtp.stu.suda.edu.cn
      • port: 465
      • starttls: false

    运行方法

    1. 从控制台运行:

      运行 console-tool.py 或者下载二进制文件,默认读取运行目录下的 config.ini 文件;可以指定 -c/--config 参数给出 Yaml 配置文件路径。

    2. 作为 package 附加于其他项目运行:

      参考 console-tool.py 的代码。实际上,可以将配置项存储为字典,调用 Poster.sender.send_email 并传入配置项即可。

    Source code(tar.gz)
    Source code(zip)
    email-sender-0.1.2-Linux_x86_64(7.24 MB)
    email-sender-0.1.2-macOS(4.76 MB)
    email-sender-0.1.2-windows_x86_64.exe(7.42 MB)
  • v0.1.1(Feb 13, 2022)

    Email Sender Version: 0.1.1 (Alpha)

    主要功能

    • 使用 SMTP 协议发送邮件
    • 支持 SSL/TLS 、 STARTTLS 加密(为保证安全,强制加密发送)
    • 支持邮件模板与邮件生成
    • 支持向多人群发邮件
    • 日志记录
    • 脚本执行

    邮件模板介绍

    使用HTML格式编写模板,遵循如下正则表达式实现文本替换:

    \{\s*%\s*(label)\s*%\s*\}
    

    例如:

    {% name %}
    

    其中,label 为定位用于替换的标签,遵守 Python 变量名命名规则,且不为 receiver, subject, receiver_name, attachments 中的任意一个, 如例子中的 name

    替换内容位于配置文件的 receivers.replace 和 template.global.replace 中, 可以分别设置每位接收者的替换信息和全局的替换信息。

    当提供了不存在的 label 会被忽略,当模板中的标签没有可替换的项时会原样输出。

    当发生替换时,整个标签都会被替换,如 {% name %},你好name=Holger 时会替换为 Holger,你好

    template 目录中提供了一个模板可供参考。

    配置文件介绍

    使用 Yaml 作为配置文件,其具体格式如下:

    mail:  # 发件方信息
      host: smtp.example.com  # smtp 服务器,请询问邮件服务提供商
      port: 587  # smtp 发送端口,请询问邮件服务提供商
      starttls: true  # 是否开启 starttls,默认为 false
      user: [email protected]  # 发送方 Email
      passwd: password  # 发送方密码或授权码
      name: Your name  # 可选,发送方名字
    template:  # 邮件模板信息
      use_file: true  # 是否提供一个 html 文件作为模板
      file: /path/to/template/filename.html
      # 当 use_file=false, 须提供 content 作为模板的内容
      global:  # 全局配置,可选(每一项都可选),下方接收者的配置会将其覆盖
        subject: For Test  # 邮件主题,和下方的至少一个不为空
        attachments: []  # 附件文件路径列表
        replace:  # 替换内容 格式为 `label: 替换的文本` 下同
          message: This is a test email.
    receivers:  # 接收者信息,为 yaml 数组
      -
        email: [email protected]  # 接收者 Email
        name: User  # 可选,接收者名字
        subject: For Test, Email Sender  # 邮件主题,和上方的至少一个不为空
        attachments: []  # 可选,附件文件路径列表
        replace:  # 替换内容 格式为 `label: 替换的文本`
          name: User
    

    (计划内)测试的(发送)邮箱:

    由于精力有限,欢迎提供不在列表内的其他邮箱测试!

    • [x] Outlook
      • host: smtp.office365.com
      • port: 587
      • starttls: true
    • [x] QQ Mail / foxmail.com
      • host: smtp.qq.com
      • port: 587 (starttls: true) 或 465 (starttls: false)
      • passwd: 填写授权码,请参考官方文档
    • [x] 163 Mail
      • host: smtp.163.com

        126,yeah.net 邮箱请自行更换服务器地址中相关参数。例如 smtp.126.com 和 smtp.yeah.net

      • port: 465
      • starttls: false
      • passwd: 填写授权码,请参考官方文档
    • [ ] Gmail (需要更多测试)
      • host: smtp.gmail.com
      • port: 587 (starttls: true) 或 465 (starttls: false)

      需要能够正常访问 Gmail 的网络环境。若无法登录,请参考官方文档

    • [x] SUDA 学生邮箱 stu.suda.edu.cn (使用该邮箱发送的邮件可能被认为是垃圾邮件)
      • host: smtp.stu.suda.edu.cn
      • port: 465
      • starttls: false

    运行方法

    安装依赖:

    $ pip3 install -r requirements.txt
    
    1. 从控制台运行:

      运行 console-tool.py,默认读取运行目录下的 config.ini 文件;可以指定 -c/--config 参数给出 Yaml 配置文件路径。

    2. 作为 package 附加于其他项目运行:

      参考 console-tool.py 的代码。实际上,可以将配置项存储为字典,调用 Poster.sender.send_email 并传入配置项即可。

    Source code(tar.gz)
    Source code(zip)
Owner
SUMSC
SUMSC
A SMTP server for use as a pytest fixture that implements encryption and authentication.

SMTPDFix: Test email, locally A simple SMTP server based on aiosmtpd for use as a fixture with pytest that supports encryption and authentication. All

James Warne 11 Sep 03, 2022
Send e-mails to teachers with specified school-website using Aula, anonymously

Information : This only works in Denmark! Send e-mails to teachers with specified school-website using Aula, anonymously. Find your school via the att

Binary.club 1 Jan 24, 2022
It s a useful project for developers ... It checks available and unavailable emails

EmailChecker It s a useful project for developers ... It checks available and unavailable emails Installation : pip install EmailChecker Domains are

Sidra ELEzz 19 Jan 01, 2023
Automated email sending application.

autoMail Automated email sending application. This application sends email to a user when added to database. Email message contains the temperature of

Bhat Owais 1 Feb 12, 2022
Python Email Sender (PES) is a program made with Python using smtplib, socket and tkinter.

Python Email Sender (PES) is a program made with Python using smtplib, socket and tkinter. This program was made for sender email to be a gmail account because that's what I used when testing it out,

Zacky2613 1 Aug 26, 2022
Esio_dev 3 Oct 15, 2021
A small system for writing via email.

A small system for writing via email.

0 Nov 24, 2021
This is the mail server that handles responses from the Contact Form

mailserver About This is the mail server that handles responses from the Contact Form Contributors ✨ Thanks goes to these wonderful people (emoji key)

IoLang 3 Jan 03, 2022
A Python Mail Server

Salmon - A Python Mail Server Download: https://pypi.org/project/salmon-mail/ Source: https://github.com/moggers87/salmon Docs: https://salmon-mail.re

Matt Molyneaux 582 Dec 30, 2022
SMTP In some vulnerable configurations, email servers can also be aggregated Use information that gives us information about the host or network Give

SMTP In some vulnerable configurations, email servers can also be aggregated Use information that gives us information about the host or network Give. The SMTP protocol supports some basic commands s

m3hr44n 1 Jan 16, 2022
Django module to easily send emails/sms/tts/push using django templates stored on database and managed through the Django Admin

Django-Db-Mailer Documentation available at Read the Docs. What's that Django module to easily send emails/push/sms/tts using django templates stored

LPgenerator 250 Dec 21, 2022
Disposable Temporary Email (Python Library)

Disposable Temporary Email (Python Library)

krypton 13 Nov 24, 2022
Dotfiles and some scripts for NeoMutt

Mutt dotfiles Robust Mutt configs with examples for the following account types: Generic IMAP/SMTP Google (Gmail/Gsuite etc) via IMAP/SMTP Microsoft O

CEUK 29 Jan 04, 2023
Send e-mails asyncronously using cron

django-yubin Django Yubin allows the programmer to control when he wants to send the e-mail in this application, making the web application to answer

APSL 44 Sep 24, 2022
Mail hosting made simple

Modoboa Modoboa is a mail hosting and management platform including a modern and simplified Web User Interface. It provides useful components such as

Modoboa 2.4k Jan 03, 2023
Django email backends and webhooks for Amazon SES, Mailgun, Mailjet, Postmark, SendGrid, Sendinblue, SparkPost and more

Django email backends and webhooks for Amazon SES, Mailgun, Mailjet, Postmark, SendGrid, Sendinblue, SparkPost and more

1.4k Jan 01, 2023
Use Django admin to manage drip campaign emails using querysets on Django's User model.

Django Drip Drip campaigns are pre-written sets of emails sent to customers or prospects over time. Django Drips lets you use the admin to manage drip

Zapier 630 Nov 16, 2022
:incoming_envelope: IMAP/SMTP sync system with modern APIs

Nylas Sync Engine The Nylas Sync Engine provides a RESTful API on top of a powerful email sync platform, making it easy to build apps on top of email.

Nylas 3.5k Dec 23, 2022
A Django email backend for Amazon's Simple Email Service

Django-SES Info: A Django email backend for Amazon's Simple Email Service Author: Harry Marr (http://github.com/hmarr, http://twitter.com/harrymarr) C

882 Dec 29, 2022
A python program capable of accessing passwords associated with emails through leaked databases.

passfind A python program capable of accessing passwords associated with emails through leaked databases. A python program capable of accessing passwo

6 Aug 14, 2022