Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lpil/gleam_sendgrid
A client for the SendGrid transactional email API
https://github.com/lpil/gleam_sendgrid
Last synced: 22 days ago
JSON representation
A client for the SendGrid transactional email API
- Host: GitHub
- URL: https://github.com/lpil/gleam_sendgrid
- Owner: lpil
- License: apache-2.0
- Created: 2022-02-09T19:22:16.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-06T13:36:21.000Z (about 1 year ago)
- Last Synced: 2024-05-01T23:05:00.611Z (8 months ago)
- Language: Gleam
- Homepage:
- Size: 18.6 KB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- awesome-gleam - gleam_sendgrid - [📚](https://hexdocs.pm/gleam_sendgrid/) - Send emails from Gleam with SendGrid (Packages / Email)
README
# Gleam SendGrid
[![Package Version](https://img.shields.io/hexpm/v/gleam_sendgrid)](https://hex.pm/packages/gleam_sendgrid)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/gleam_sendgrid/)A client for SendGrid's API, enabling Gleam programs to send emails.
## Usage
Add this package to your Gleam project.
```sh
gleam add gleam_sendgrid
```And then send some emails!
```gleam
import gleam/sendgrid
import gleam/hackneypub fn main() {
let api_key = "your SendGrid API key here"// Construct an email
let email =
sendgrid.Email(
to: ["[email protected]"],
sender_email: "[email protected]",
sender_name: "Mike",
subject: "Hello, Joe!",
content: sendgrid.TextContent("System still working?"),
)// Prepare an API request
let request = sendgrid.dispatch_request(email, api_key)// Send it with a HTTP client of your choice
let assert Ok(response) = hackney.send(request)// A status of 202 indicates that the email has been sent
let assert 202 = response.status
}
```