<p align="center">
<img
alt="Send emails with Rust — Resent"
src="https://raw.githubusercontent.com/resentmail/resent-node/main/assets/banner.jpg"
width="100%"
/>
</p>
<p align="center">
<a href="https://developers.resent.one">Documentation</a>
·
<a href="https://resent.one">Website</a>
·
<a href="https://crates.io/crates/resent">crates.io</a>
·
<a href="https://github.com/resentmail/resent-rust">GitHub</a>
</p>
# Resent Rust SDK
The official Rust library for [Resent](https://resent.one) transactional email.
## Install
```toml
[dependencies]
resent = "0.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
```
```bash
cargo add resent
cargo add tokio --features macros,rt-multi-thread
```
## Setup
1. Verify a sending domain in the [Resent dashboard](https://resent.one/app/settings/domains/)
2. Create an API key under [Settings → API keys](https://resent.one/app/settings/api-keys/)
3. Store it as `RESENT_API_KEY`
## Usage
```rust
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
```rust
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
- [Getting started](https://developers.resent.one)
- [Send transactional email](https://developers.resent.one/guides/send-transactional-email)
- [Framework guides](https://developers.resent.one/guides/frameworks)
- [API overview](https://developers.resent.one)
## License
MIT © [Resent](https://resent.one)