Skip to content

edgee-cloud/sendgrid-component

SendGrid component for Edgee

Coverage Status GitHub issues Edgee Component Registry

This component provides a simple way to send emails via SendGrid on Edgee, served directly at the edge. You map the component to a specific endpoint such as /contact, and then you invoke it from your frontend code.

Quick Start

  1. Download the latest component version from our releases page
  2. Place the sendgrid.wasm file in your server (e.g., /var/edgee/components)
  3. Add the following configuration to your edgee.toml:
[[components.edge_functions]]
id = "sendgrid"
file = "/var/edgee/components/sendgrid.wasm"
settings.api_key = "SG.abc.xyz"
settings.from_email = "[email protected]" # your verified sender identity
settings.subject = "Contact request" # optional (only used when no template_id is provided)
settings.template_id = "d-abcxyz" # optional
settings.edgee_path = "/path" # exact match
settings.edgee_path_prefix = "/prefix" # will match /prefix/anything

Note that either edgee_path or edgee_path_prefix must be set, but not both.

How to use the HTTP endpoint

You can send requests to the endpoint as follows:

// using static text
await fetch('/contact', {
  method: 'POST',
  body: JSON.stringify({
    "message": "hello world!", // static content (plain text)
    "email": "[email protected]"
    })
});

// using a dynamic template
await fetch('/contact', {
  method: 'POST',
  body: JSON.stringify({
    "data": {"name": "John"}, // dynamic data for your template
    "email": "[email protected]"
    })
});

Development

Building from Source

Prerequisites:

Build command:

edgee component build

Test command (with local HTTP emulator):

edgee component test

Test coverage command:

make test.coverage[.html]

Contributing

Interested in contributing? Read our contribution guidelines

Security

Report security vulnerabilities to [email protected]

About

SendGrid Edgee Component

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •