## Prerequisites

Before you start, you'll need:

- A Resend [API key](/guides/get-started-create-an-api-key)
- A [verified domain](/guides/get-started-add-a-domain)

## Guide

::::steps
:::step{title="Install"}
First, create a rust project with cargo and `cd` into it.

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
cargo init resend-rust-example
cd resend-rust-example
```

Next, add add the Rust Resend SDK as well as [Tokio](https://tokio.rs):

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
cargo add resend-rs
cargo add tokio -F macros,rt-multi-thread
```

The Rust SDK is Async-first so Tokio is needed.
:::

:::step{title="Send email"}
```rust theme={"theme":{"light":"github-light","dark":"vesper"}}
use resend_rs::types::CreateEmailBaseOptions;
use resend_rs::{Resend, Result};

#[tokio::main]
async fn main() -> Result<()> {
  let resend = Resend::new("re_xxxxxxxxx");

  let from = "Acme <onboarding@resend.dev>";
  let to = ["delivered@resend.dev"];
  let subject = "Hello World";

  let email = CreateEmailBaseOptions::new(from, to, subject)
    .with_html("<strong>It works!</strong>");

  let _email = resend.emails.send(email).await?;

  Ok(())
}
```
:::

:::step{title="Reading the API key"}
Instead of using `Resend::new` and hardcoding the API key, the `RESEND_API_KEY` environment variable
can be used instead. Use `Resend::default()` in that scenario instead.

Another popular option is to use a `.env` file for environment variables. You can use the
[`dotenvy`](https://crates.io/crates/dotenvy) crate for that:

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
cargo add dotenvy
```

```rust theme={"theme":{"light":"github-light","dark":"vesper"}}
// main.rs
use dotenvy::dotenv;
use resend_rs::types::CreateEmailBaseOptions;
use resend_rs::{Resend, Result};

#[tokio::main]
async fn main() -> Result<()> {
  let _env = dotenv().unwrap();

  let resend = Resend::default();

  let from = "Acme <onboarding@resend.dev>";
  let to = ["delivered@resend.dev"];
  let subject = "Hello World";

  let email = CreateEmailBaseOptions::new(from, to, subject)
    .with_html("<strong>It works!</strong>");

  let _email = resend.emails.send(email).await?;

  Ok(())
}
```

```toml theme={"theme":{"light":"github-light","dark":"vesper"}}
# .env
RESEND_API_KEY=re_xxxxxxxxx
```
:::
::::

## Examples

::::card-grid
:::card{title="Basic Send" href="https://github.com/resend/resend-examples/blob/main/rust-resend-examples/examples/basic_send.rs" icon="arrow-up-right-from-square"}
Basic email sending
:::

:::card{title="Attachments" href="https://github.com/resend/resend-examples/blob/main/rust-resend-examples/examples/with_attachments.rs" icon="arrow-up-right-from-square"}
Send emails with file attachments
:::

:::card{title="Templates" href="https://github.com/resend/resend-examples/blob/main/rust-resend-examples/examples/with_template.rs" icon="arrow-up-right-from-square"}
Send emails using Resend hosted templates
:::

:::card{title="Scheduling" href="https://github.com/resend/resend-examples/blob/main/rust-resend-examples/examples/scheduled_send.rs" icon="arrow-up-right-from-square"}
Schedule emails for future delivery
:::

:::card{title="Audiences" href="https://github.com/resend/resend-examples/blob/main/rust-resend-examples/examples/audiences.rs" icon="arrow-up-right-from-square"}
Manage contacts and audiences
:::

:::card{title="Domains" href="https://github.com/resend/resend-examples/blob/main/rust-resend-examples/examples/domains.rs" icon="arrow-up-right-from-square"}
Create and manage sending domains
:::

:::card{title="Inbound Webhooks" href="https://github.com/resend/resend-examples/blob/main/rust-resend-examples/examples/inbound.rs" icon="arrow-up-right-from-square"}
Receive and process inbound emails
:::

:::card{title="Double Opt-in" href="https://github.com/resend/resend-examples/blob/main/rust-resend-examples/examples/double_optin_subscribe.rs" icon="arrow-up-right-from-square"}
Double opt-in subscription flow
:::

:::card{title="Axum App" href="https://github.com/resend/resend-examples/tree/main/rust-resend-examples/axum_app" icon="arrow-up-right-from-square"}
Full Axum web framework application
:::
::::

## Related pages

- [Send emails with Axum](./get-started-send-with-axum.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
