Giter Club home page Giter Club logo

email-sender's Introduction

email-sender

A service to send email messages.

Features

  • Multiple email service integrations that can be easily switched;
  • Send custom emails or transactionals with POST requests;
  • Transactional messages from jinja2 templates
  • Requests must be authenticated with the x-api-key header;
  • Request body validation with pydantic;
  • Auto-generated API docs with fastapi
  • Task queue for asyncronous processing of email requests with celery;

Architecture

architecture

Resources (all on free tiers)

Development

Requirements

Installing

Install dependencies

make install

Testing

make test

Running

make run

Access the API documentation on http://localhost:8000/docs and use the default API_KEY to authenticate (check it on Settings class).

You can run the app and test its API as is, but no emails will be sent. To do so, you'll have to set up an email service.

Transactional messages make it easier to trigger events from other services, try including a new Transactional based on your needs.

Setting up an email service

The email service can be chosen by setting the EMAIL_SERVICE environment variable to one of the values available on EmailService enum ("mailjet" by default).

After choosing which service to use you'll need to:

  1. Sign up on its platform;
  2. Verify your email address as an authorized sender;
  3. Generate and set the API key as environment variable (check Settings class for naming references);

The verified email address must be used either as the from attribute on requests or as the DEFAULT_EMAIL_ADDRESS environment variable.

If the available services do not suffice, you can add a new email service integration.

Adding an email service integration

There are many email services available out there that you can choose from. If this project does not yet integrate with it, you can do so by:

  1. Creating a YourEmailServiceAdapter class that extends BaseAdapter and implements its send method;
  2. Adding a value to EmailService enum corresponding to your new service;
  3. Mapping your new service on the ADAPTERS dictionary, so it can be chosen from by the EMAIL_SERVICE environment variable;

Including a new Transactional

You should be able to include a new Transactional message type by:

  1. Adding a jinja2 flavored template file to the /templates folder;
  2. Mapping it as a new value on the Transactional enum including its type, that should uniquely identify the transactional, and its template file name;

Now your new Transactional can be triggered from the API by specifying its identifier and passing the data it needs to render.

Deployment

Heroku

The app.json, Procfile, and runtime.txt files on this repository are specific for deployment on Heroku. It can be done by clicking the following button:

Deploy

email-sender's People

Contributors

dependabot[bot] avatar umluizlima avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.