Skip to content

tabenius/functions-python-sendgrid-email

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless Function in Python: Email

Introduction

This repository contains a Email function written in Python using SendGrid API, a MJML transpiler [https://pypi.org/project/mjml-python/] and minimum part of the Django template language. You are able to send an email using Sendgrid's API to email addresses with or without DMARCS.

You can deploy it on DigitalOcean's App Platform as a Serverless Function component. Documentation is available at https://docs.digitalocean.com/products/functions.

Requirements

Deploying the Function

Clone it and modify it to your taste...

# deploy the project, using a remote build so that compiled executable matched runtime environment
> doctl serverless deploy fn-py-mailer --remote-build
Deploying 'fn-py-mailer'
  to namespace 'fn-...'
  on host 'https://faas-...'
Submitted action 'emails' for remote building and deployment in runtime python:default (id: ...)

Deployed functions ('doctl sls fn get <funcName> --url' for URL):
  - channelin/emails

OBSOLETE: Using the Function

Below is OBSOLETE usage from DigitalOcean's sample

doctl serverless functions invoke channelin/emails -p from:user@do.com to:user@gmail.com subject:Sammy content:Good Morning from Sammy.
{
  "body": "email sent"
}

To send an email using curl:

curl -X PUT -H 'Content-Type: application/json' {your-DO-app-url} -d '{"from":"user@do.com", "to":"user@gmail.com", "subject": "Sammy", "content":"Good Morning from Sammy!"}' 

Learn More

You can learn more about Functions and App Platform integration in the official App Platform Documentation.

About

Sending emails via Sendgrid API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 95.0%
  • Shell 5.0%