Wasm Functions
SendGrid
Send transactional emails using SendGrid’s powerful email delivery platform, powered by edge functions.
Find it on GitHub: /edgee-cloud/sendgrid-component
A WebAssembly component that provides a simple way to send emails via SendGrid directly from the edge. This component can be mapped to a specific endpoint (like /contact
) and supports both static text and dynamic email templates.
Features
- SendGrid Integration: Direct integration with SendGrid’s email API
- Template Support: Use SendGrid’s dynamic email templates
- Configurable Endpoint: Set custom paths for your email sending endpoint
- Edge Performance: Fast email processing directly at the edge
- Static and Dynamic Content: Support for both static text and templated emails
- WebAssembly Performance: Secure, fast execution in a sandboxed environment
Getting Started
To integrate SendGrid with your project:
- Create a SendGrid account and generate an API key
- Verify your sender email address in SendGrid
- Open the Edgee console and navigate to your project’s Components
- Select “Add a component” and choose
edgee/sendgrid
from the list of available edge functions - Configure the following settings:
- API Key: Your SendGrid API key
- From Email: Your verified sender email address
- Subject: Default email subject line (optional)
- Template ID: SendGrid template ID for dynamic emails (optional)
- Path Configuration: Set the email sending endpoint path (e.g.,
/contact
)
- Click Save to activate the email sending endpoint
Usage
Once configured, you can send emails by making POST requests to your configured endpoint:
Request Formats
Static Text Email
Dynamic Template Email
Template Support
If you configure a template_id
, the component will use SendGrid’s dynamic template system with the provided data in the data
field.
Use Cases
- Contact Forms: Process contact form submissions
- Transactional Emails: Order confirmations and notifications
- User Onboarding: Welcome emails and account setup
- Support Tickets: Automated support email responses
- Marketing Communications: Newsletter and promotional emails
- System Notifications: Alert emails for system events
Example Integrations
Order Confirmation Email
Welcome Email
Error Handling
The edge function provides comprehensive error handling:
- 400 Bad Request: Invalid request format or missing required fields
- 401 Unauthorized: Invalid API key or authentication failure
- 403 Forbidden: Insufficient permissions or suspended account
- 413 Payload Too Large: Email content or attachments too large
- 429 Too Many Requests: Rate limit exceeded
- 500 Internal Server Error: SendGrid API error