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
Send email notification when receiving Facebook message.

Send email notification when receiving Facebook message.

Radon Rosborough 4 May 08, 2022
send email & telegram message whenever an analog in is recieved

send email & telegram message whenever an analog in is recieved (so when attached to an alarm siren out it will alert via mail)

Naor Livne 2 Feb 11, 2022
A CLI client for sending text emails. (Currently only gmail supported)

emailCLI A CLI client for sending text emails. (Currently only gmail supported)

Amethist 3 Dec 17, 2021
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
check disk storage's amount and if necessary, send alert message by email

DiskStorageAmountChecker What is this script? (このスクリプトは何ですか?) This script check disk storage's available amount of specified servers and send alerting

Hajime Kurita 1 Oct 22, 2021
This library is helpful when creating accounts, it has everything you need for this

AccountGeneratorHelper Library to facilitate accounts generation. Unofficial API for temp email services. Receive SMS from free services. Parsing and

Denis 52 Jan 07, 2023
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
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
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

muntazir halim 13 Sep 15, 2022
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

David Barragán Merino 77 Aug 30, 2021
An automation program that checks whether email addresses are real, whether they exist and whether they are a validated mail

Email Validator It is an automation program that checks whether email addresses are real, whether they exist and whether they are a validated mail. Re

Ender MIRIZ 4 Dec 22, 2021
Mailrise is an SMTP server that converts the emails it receives into Apprise notifications

Mailrise is an SMTP server that converts the emails it receives into Apprise notifications. The intended use case is as an email relay for a home lab or network. By accepting ordinary email, Mailrise

Ryan Young 293 Jan 07, 2023
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

Pascal van Kooten 2.4k Dec 31, 2022
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
EmailAll - a powerful Email Collect tool

EmailAll A powerful Email Collect tool 0x1 介绍 😲 EmailAll is a powerful Email Co

473 Dec 22, 2022
Simple Email Sender using Python 3.

Email Sender 使用 Python 3 实现的简单邮件发送工具。 Version: 0.1.2 (Beta) 主要功能 使用 SMTP 协议发送邮件 支持 SSL/TLS 、 STARTTLS 加密(为保证安全,强制加密发送) 支持邮件模板与邮件生成 支持向多人群发邮件 日志记录 脚本执行

SUMSC 1 Feb 13, 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
SMTP checker to check Mail Access via SMTP

SMTP checker to check Mail Access via SMTP with easy usage ! Medusa has been written and tested with Python 3.8. It should run on any OS as long as Python and all dependencies are installed.

h3x0 23 Dec 05, 2022
Euserv_extend captcha solver + pin code(Gmail)

Euserv_extend captcha solver + pin code(Gmail)

19 Nov 30, 2022
Django module to easily send templated emails using django templates, or using a transactional mail provider (mailchimp, silverpop, etc.)

Django-Templated-Email Info: A Django oriented templated email sending class Author: Bradley Whittington (http://github.com/bradwhittington, http://tw

Vinta Software 659 Dec 27, 2022