55

Drymail – A minimalist but complete email framework for Python

 5 years ago
source link: https://www.tuicool.com/articles/hit/773yqu
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

drymail

Makes sending emails easy and DRY — For Python 3.

Drymailis a minimalist wrapper over Python’s existing smtplib and email libraries, designed to be friendly but unrestrictive. Here’s how you might send a simple email with an attachment using drymail .

from drymail import SMTPMailer, Message

client = SMTPMailer(host='smtp.email.com', user='johndoe', password='password', tls=True)
message = Message(subject='Congrats on the new job!', sender=('John Doe', '[email protected]'), 
                  receivers=[('Jane Doe', '[email protected]'), '[email protected]'])
with open('congrats.pdf', 'rb') as pdf_file:
    message.attach(filename='congrats.pdf', data=pdf_file.read(), mimetype='application/pdf')

client.send(message)

Features

  • Supports creating email with HTML content, plaintext content, or both!
  • Supports mentioning contacts in the “John Doe" <[email protected]> format.
  • Support standard headers like CC , BCC , Reply-To and Authors .
  • Supports injecting custom headers.
  • Supports adding attachments.
  • And most importantly — the library being minimalist, it doesn’t restrict you in any way like some of the most fancier email frameworks do.

Installation

Install drymail by running —

$ pip3 install drymail

Documentation

Documentation is available at https://drymail.readthedocs.io/

Contribute

All kinds of contribution are welcome.

License

This project is licensed under the MIT license.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK