A simple SMTP client.
Project description
EasySMTP: A simple SMTP client
EasySMTP is a simple and lightweight SMTP client written in pure Python.It is distributed as a single file module and has no dependencies other than the Python Standard Library.
Features
- Send plain text email
- Send HTML email
- Send email with attachments
- Guess MIME type of attachments
- Send email with embedded images
- Built-in well-known SMTP servers configuration
Installation
Install the latest stable release with pip install easysmtp or download easysmtp.py into your project.
Usage
To use it, you need to enable SMTP for your email. You can find instructions on how to enable SMTP for your email service provider on the internet.
import easysmtp
from_addr = 'user@gmail.com'
smtp_username = from_addr # SMTP login username. It's usually your email address.
smtp_password = 'password'
smtp = easysmtp.EasySMTP()
smtp.config(from_addr,
username=smtp_username,
password=smtp_password,)
to_addr = 'to@gmail.com'
subject = 'Hello'
# Send a plain text email
smtp.send_mail(from_addr, to_addr, subject, body='Hello world!')
# Send an HTML email
smtp.send_mail(from_addr, to_addr, subject, html_body='<h1>Hello world!</h1>')
# Send an email with attachments
smtp.send_mail(from_addr, to_addr, subject, body='Hello world!', attachments=['README.md'])
# Send an email with embedded images
html_body = '<p>Hello world!</p><img src="cid:test.png">'
smtp.send_mail(from_addr, to_addr, subject, html_body=html_body, attachments=['test.png'])
# or more control with attachment cid
attachments = [Attachment("tests/测试.png", cid="test.png")]
smtp.send_mail(from_addr, to_addr, subject, html_body=html_body, attachments=attachments)
Built-in SMTP servers
- 126.com
- 163.com
- gmail.com
- outlook.com
- qq.com
- sina.com
- yahoo.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easysmtp-0.1.4.tar.gz.
File metadata
- Download URL: easysmtp-0.1.4.tar.gz
- Upload date:
- Size: 54.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.19.2 CPython/3.11.2 Linux/6.1.0-25-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89fee47241faa512797f09d66ba20a891aa266e5c98ba6c4a949e3ca42ebf62f
|
|
| MD5 |
bcead4d69c1f8e65b8d508bcf97490c6
|
|
| BLAKE2b-256 |
97895a009e12a0436b4f06ca355bf793262f8deef3d540d86882f67622fd1da1
|
File details
Details for the file easysmtp-0.1.4-py3-none-any.whl.
File metadata
- Download URL: easysmtp-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.19.2 CPython/3.11.2 Linux/6.1.0-25-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe875c87adca6af0e0931034c3e6149ee98dde50e8a5b7f47fcebda51943d8d6
|
|
| MD5 |
52953a487f3af94e1ce956ca803df879
|
|
| BLAKE2b-256 |
8382e8606693780dd0fbebe89016adf608c0ab89a638cd1f3869ee2775535de1
|