Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Simplyify sending HTML emails

Project description

Email To Documentation Status Updates

Simplyify sending HTML emails

Judgement rendered by:

Codacy Code Health Code Climate scrutinizer


The built in Python modules for sending email are powerful, but require a lot of boilerplate to write an HTML formatted email.

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib

message = MIMEMultipart('alternative')
message['Subject'] = 'Test'
message['From'] = ''
message['To'] = ''

message.attach(MIMEText('# A Heading\nSomething else in the body', 'plain')
message.attach(MIMEText('<h1 style="color: blue">A Heading</a><p>Something else in the body</p>', 'html')

server = smtplib.SMTP('', 587)
server.login('', 'password')
server.sendmail('', '', message.as_string())

With email_to sending a simple email becomes much more succint.

import email_to

server = email_to.EmailServer('', 587, '', 'password')
server.quick_email('', 'Test',
                   ['# A Heading', 'Something else in the body'],
                   style='h1 {color: blue}')

email_to also supports building a message up, line by line. This is especially useful for monitoring scripts where there may be several different conditions of interest.

import email_to

server = email_to.EmailServer('', 587, '', 'password')

message = server.message()
message.add('# Oh boy, something went wrong!')
message.add('- The server had a hiccup')
message.add('- The power went out')
message.add('- Blame it on a rogue backhoe') = 'h1 { color: red}'

message.send('', 'Things did not occur as expected')

Additionally if the server details are not known at the beginning of the message, that can be handled easily too.

import email_to

message = email_to.Message('# Every thing is ok')
message.add('Everything has been running fine for days.')
message.add('Probably time to build something new and break everything') = 'h1 { color: green }'

server = email_to.EmailServer('', 587, '', 'password')
server.send_message(message, '', 'Things are awesome')


This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.


0.1.0 (2017-09-27)

  • First release on PyPI.

Project details

Download files

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

Files for email-to, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size email_to-0.1.0-py2.py3-none-any.whl (7.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size email_to-0.1.0.tar.gz (14.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page