Skip to content

digitalocean/sample-functions-python-sendgrid-email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample Function: Python "Sendgrid Emails"

Introduction

This repository contains a sample Sendgrid Email function written in Python. 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 this repo
git clone [email protected]:digitalocean/sample-functions-python-sendgrid-email.git
# deploy the project, using a remote build so that compiled executable matched runtime environment
> doctl serverless deploy sample-functions-python-sendgrid-email --remote-build
Deploying 'sample-functions-python-sendgrid-email'
  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):
  - sample/emails

Using the Function

doctl serverless functions invoke sample/emails -p from:[email protected] to:[email protected] 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":"[email protected]", "to":"[email protected]", "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

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published