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.
- Download the latest component version from our releases page
- Place the
sendgrid.wasm
file in your server (e.g.,/var/edgee/components
) - 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.
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]"
})
});
Prerequisites:
Build command:
edgee component build
Test command (with local HTTP emulator):
edgee component test
Test coverage command:
make test.coverage[.html]
Interested in contributing? Read our contribution guidelines
Report security vulnerabilities to [email protected]