Skip to main content

Quick-and-Dirty Email Sender

Project description

quick-email

Quick-and-Dirty Email Sender

Build Status Coverage Status PyPI version

Emails are ubiquitous, but not super-straightforward from a programming standpoint. The standards in use (SMTP, MIME) are powerful, but complex if you want to do anything nicer than a simple plain-test email. This library was built and iterated upon for my personal projects, and it might just help you too.

Supports both Python >=v2.7 and >=3.4.

Installation

pip install quick-email

Usage

Send Email

quick_email.send_email(host, port, send_from, subject[, send_to[, send_cc[, send_bcc[, plain_text[, html_text[, attachment_list[, inline_attachment_dict[, username[, password[, require_starttls]]]]]]]]]])

My super-useful utility function. Creates and sends an email in one fell swoop. All parameters are passed to the functions below.

Create Message

quick_email.build_msg(send_from, subject[, send_to[, send_cc[, send_bcc[, plain_text[, html_text[, attachment_list[, inline_attachment_dict]]]]]]])

Creates a email.message.Message for deferred sending or additional preparing.

Email addresses can be a string (either of form example@example.com or Example Name <example@example.com>), or a tuple, as returned by email.utils.parseaddr.

send_from is a single email address.

subject is the Subject string of the email.

send_to, send_cc, and send_bcc are all either singular email addresses, or lists of email addresses if you have multiple recipients. At least one address must be present among the parameters, otherwise an AssertionError will be raised.

plain_text is the plain-text part of the email. html_text is the HTML part of the email. You can include one or both, but if no text is present, an AssertionError will be raised.

attachment_list is an optional list of quick_email.Attachments.

inline_attachment_dict is an optional dict of str: quick_email.Attachment form. The key is the CID of your attachment. In many email clients, you can include images inline in the HTML (ie <img src="...">). However, if the image you want to display is an attachment (and not at some URL), it's a little trickier. You must give your attachment a Content-ID (CID), and your img tag must look like <img src="cid:my_attachment_cid">. This may be preferred to the inline-base64 encoding (ie <img src="data:image/jpeg;base64,...">).

class quick_email.Attachment(filename, bytes)

filename is the filename string.

bytes is the bytes-like object of the content.

Send Message

quick_email.send_msg(msg, host, port[, username[, password[, require_starttls]]])

Sends a email.message.Message to its recipients.

msg is the email.message.Message, which you may have built using quick_email.build_msg, or handcrafted youself.

host is the host string to connect to. Usually a FQDN, or an IP address.

port is the port number to connect to. Usually 25 for un-encrypted email.

username is the username of a username/password combo used to authenticate. Leave it off if your service is unauthenticated.

password is the password of a username/password combo used to authenticate. Leave it off if your service is unauthenticated.

require_starttls is a flag whether to request the message sending be encrypted. Defaults to False, but turn it on if you can.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quick-email-0.4.4.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quick_email-0.4.4-py2.py3-none-any.whl (4.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file quick-email-0.4.4.tar.gz.

File metadata

  • Download URL: quick-email-0.4.4.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.21.0 CPython/3.6.4

File hashes

Hashes for quick-email-0.4.4.tar.gz
Algorithm Hash digest
SHA256 afcd54d92914b343ca9c773ac6a8db8475f7bec25342708370fa4e91385b53bc
MD5 110e0f7535e2fdf2da40ea55da5e535d
BLAKE2b-256 871075c754174063907750daba6618c6a404eba891742197cb902b8381b4eed3

See more details on using hashes here.

File details

Details for the file quick_email-0.4.4-py2.py3-none-any.whl.

File metadata

  • Download URL: quick_email-0.4.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.21.0 CPython/3.6.4

File hashes

Hashes for quick_email-0.4.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7c48e2f60450311777bac189d46993b13dc776948fe0a3a7ee153322e34d587a
MD5 bd942158c3cc7a09f83a282607b3eddb
BLAKE2b-256 d8de93541e17cc103f88e2b00b50e80aa1465e5db876e9f80eed823a9ebd8c00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page