Resent Rust SDK
The official Rust library for Resent transactional email.
Install
[dependencies]
resent = "0.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
cargo add resent
cargo add tokio --features macros,rt-multi-thread
Setup
- Verify a sending domain in the Resent dashboard
- Create an API key under Settings → API keys
- Store it as
RESENT_API_KEY
Usage
use resent::{Resent, SendEmail};
#[tokio::main]
async fn main() -> Result<(), resent::Error> {
let resent = Resent::new(std::env::var("RESENT_API_KEY").expect("RESENT_API_KEY"));
let result = resent
.emails()
.send(
SendEmail::new(
"Acme <noreply@yourdomain.com>",
["you@example.com"],
"Hello World",
)
.html("<strong>It works!</strong>"),
)
.await?;
println!("{:?}", result.submission_id);
Ok(())
}
Send email using HTML
let result = resent
.emails()
.send(SendEmail {
from: "Acme <noreply@yourdomain.com>".into(),
to: vec!["you@example.com".into()],
subject: "Hello World".into(),
html: Some("<strong>It works!</strong>".into()),
..Default::default()
})
.await?;
Docs
License
MIT © Resent