GithubHelp home page GithubHelp logo

email_to's Introduction

Email To

image

image

Documentation Status

Updates

Simplyify sending HTML emails

Judgement rendered by:

Codacy

Code Health

Code Climate

scrutinizer

Features

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'] = '[email protected]'
message['To'] = '[email protected]'

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('smtp.gmail.com', 587)
server.starttls()
server.login('[email protected]', 'password')
server.sendmail('[email protected]', '[email protected]', message.as_string())
server.quit()

With email_to sending a simple email becomes much more succint.

import email_to

server = email_to.EmailServer('smtp.gmail.com', 587, '[email protected]', 'password')
server.quick_email('[email protected]', '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('smtp.gmail.com', 587, '[email protected]', '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')
message.style = 'h1 { color: red}'

message.send('[email protected]', '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')
message.style = 'h1 { color: green }'

server = email_to.EmailServer('smtp.gmail.com', 587, '[email protected]', 'password')
server.send_message(message, '[email protected]', 'Things are awesome')

Credits

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.