---
title: Rust
description: Send emails via Reloop SMTP using Lettre in Rust.
---
> For the complete documentation index, see [llms-docs.txt](/llms-docs.txt) or the site index [llms.txt](/llms.txt). Full docs corpus: [llms-full-docs.txt](/llms-full-docs.txt). Prefer markdown URLs (append `.md`) for agent consumption. Product skill: [skill.md](/skill.md).


# Rust SMTP Integration

Send emails in Rust using the high-performance **Lettre** crate.

[View complete runnable example on GitHub ↗](https://github.com/reloop-labs/reloop-examples/tree/main/smtp-rust)

## Installation

Add `lettre` to your `Cargo.toml`:

```toml
[dependencies]
lettre = "0.11"
```

## Code Example

```rust
use lettre::transport::smtp::authentication::Credentials;
use lettre::{Message, SmtpTransport, Transport};
use std::env;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let api_key = env::var("RELOOP_API_KEY")?;

    let email = Message::builder()
        .from("onboarding@reloop.sh".parse()?)
        .to("delivered@resend.dev".parse()?)
        .subject("Hello from Lettre")
        .header(lettre::message::header::ContentType::TEXT_HTML)
        .body(String::from("<p>Congrats on sending your first email via Reloop SMTP using Lettre!</p>"))?;

    let creds = Credentials::new("reloop".to_string(), api_key);

    // Open a local connection on port 587
    let mailer = SmtpTransport::starttls_relay("smtp.reloop.sh")?
        .credentials(creds)
        .build();

    // Send the email
    match mailer.send(&email) {
        Ok(_) => println!("Email sent successfully!"),
        Err(e) => panic!("Could not send email: {:?}", e),
    }

    Ok(())
}
```

<RelatedTopics>
  <RelatedTopic icon="smtp" title="SMTP Integration Overview" href="/docs/examples/smtp/introduction" />
  <RelatedTopic icon="siRust" title="Rust Axum Integration Guide" href="/docs/examples/rust/axum" />
  <RelatedTopic icon="siGo" title="Go SMTP Guide" href="/docs/examples/smtp/go" />
</RelatedTopics>
