Coder Social home page Coder Social logo

emailgen's Introduction

EmailGen

Python Email Generation for Humans

EmailGen is a python port of the great mailgen engine for Node.js. Check their work, it's awesome! It's a package that generates clean, responsive HTML e-mails for sending transactional e-mails (welcome e-mails, reset password e-mails, receipt e-mails and so on), and associated plain text fallback.

Installation

$ pip install emailgen

Usage

Start by importing the library and configuring a generator.

import emailgen

# For most simple use cases, this should be all you need to define.
generator = emailgen.Generator(product={
    "name": "Example Corporation",
    "link": "https://example.com/",
    "logo": "https://example.com/static/images/logo.png",
    "copyright": "Copyright © 2017, Example Corporation. All rights reserved.",
    "trouble": "If you're having trouble viewing this email in your email, view it <a href="#">here</a>."
})

Next, you can generate an email by creating an instance of Email, adding in the content pieces you want and then generating the email with your newly configured generator.

table = emailgen.Table(["Service", "Maintenance Window"])  # Enter in the headers
table.add_row(["Service A", "Jan 1 00:00 - Jan 1: 01:00"])  # Enter in the values for the columns
table.add_row(["Service B", "Jan 1 01:00 - Jan 1: 02:00"])  #  in the same order as the headers
table.add_row(["Service C", "Jan 1 02:00 - Jan 1: 03:00"])
table.add_row(["Service D", "Jan 1 03:00 - Jan 1: 04:00"])

email = emailgen.Email("John Doe")  # Enter in the name of the recipient
email.add_intro("Welcome to our product! We're very excited to have you on board.")
email.add_table(table)
email.add_action("To get started with Example, please click here:",
                 emailgen.Button("Confirm your account", "http://example.com/confirm-account"))
email.add_outros("Need help, or have questions? Just reply to this email, we'd love to help.")

html_output = generator.html(email)
plain_text_output = generator.plain(email)

emailgen's People

Contributors

aisola avatar

Watchers

 avatar  avatar

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.