Giter VIP home page Giter VIP logo

fastapi-mail's Introduction

Fastapi-mail

The fastapi-mail simple lightweight mail system, sending emails and attachments(individual && bulk)

WARNING!

This is a uvicorn compatible fork of the original library, which ditches aiosmtplib due to it using asyncio Locks, which breaks down with uvicorn + gunicorn (for some reason).

This means that the sending logic in this library is synchronous in order to ensure functionality.

MIT licensed GitHub stars GitHub forks GitHub issues Downloads

πŸ”¨ Installation

 $ pip install fastapi-mail

Documentation: FastApi-MAIL

The key features are:

  • sending emails with either with FastApi or using asyncio module
  • sending emails using FastApi background task managment
  • sending files either from form-data or files from server
  • Using Jinja2 HTML Templates
  • email utils (utility allows you to check temporary email addresses, you can block any email or domain)
  • email utils has two available classes DefaultChecker and WhoIsXmlApi
  • Unittests using FastapiMail

More information on Getting-Started

Guide

from fastapi import FastAPI, BackgroundTasks, UploadFile, File, Form
from starlette.responses import JSONResponse
from starlette.requests import Request
from fastapi_mail import FastMail, MessageSchema,ConnectionConfig
from pydantic import BaseModel, EmailStr
from typing import List



class EmailSchema(BaseModel):
    email: List[EmailStr]


conf = ConnectionConfig(
    MAIL_USERNAME = "YourUsername",
    MAIL_PASSWORD = "strong_password",
    MAIL_FROM = "[email protected]",
    MAIL_PORT = 587,
    MAIL_SERVER = "your mail server",
    MAIL_TLS = True,
    MAIL_SSL = False,
    USE_CREDENTIALS = True,
    VALIDATE_CERTS = True
)

app = FastAPI()


html = """
<p>Thanks for using Fastapi-mail</p> 
"""


@app.post("/email")
async def simple_send(email: EmailSchema) -> JSONResponse:

    message = MessageSchema(
        subject="Fastapi-Mail module",
        recipients=email.dict().get("email"),  # List of recipients, as many as you can pass 
        body=html,
        subtype="html"
        )

    fm = FastMail(conf)
    await fm.send_message(message)
    return JSONResponse(status_code=200, content={"message": "email has been sent"})     

List of Examples

For more examples of using fastapi-mail please check example section

Contributing

Feel free to open issues and send pull requests.

Contributors ✨

Thanks goes to these wonderful people (🚧):


🚧
🚧

Sabuhi Shukurov

πŸ’¬ πŸ‘€ 🚧

Tural Muradov

πŸ“– πŸ‘€ πŸ”§

Hasan Aliyev

πŸ“– 🚧 πŸ‘€

Ashwani

🚧

Leon Xu

🚧

Gabriel Oliveira

πŸ“– 🚧

Onothoja Marho

πŸ“– 🚧 πŸ”§

Tim Kiely

🚧

Dmitriy Solodkiy

🚧

Peter Boers

🚧

James Valentine

πŸ“– 🚧 πŸ”§

Gogoku

πŸ“– 🚧 πŸ”§

Kucera-Lukas

πŸ“– 🚧 πŸ”§

LLYX

πŸ“– 🚧 πŸ”§

floodpants

🚧

AndrΓ© Felipe Dias

πŸ“– πŸ‘€ πŸ”§

Wojtek Jurkowlaniec

πŸ“– πŸ‘€ πŸ”§

This project follows the all-contributors specification. Contributions of any kind are welcome!

Before you start please read CONTRIBUTING

LICENSE

MIT

fastapi-mail's People

Contributors

sabuhish avatar turall avatar dmitriysolodkiy avatar kucera-lukas avatar tharising avatar aliyevh avatar floodpants avatar pboers1988 avatar maestro-1 avatar dependabot[bot] avatar gogoku avatar wjurkowlaniec avatar thetimkiely avatar sionabes avatar satwikkansal avatar msb avatar mmasztalerczuk avatar llyx avatar nymann avatar trinqk avatar jansenicus avatar isaiaht-tech avatar eltociear avatar gabrielponto avatar imaskm 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.