Documentation Index
Fetch the complete documentation index at: https://jetemail.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Rust SDK
The jetemail crate is the official Rust SDK for JetEmail transactional email (MIT license, async with Tokio).
Create a transactional API key in the dashboard: Outbound → Keys → Add API key. Use that key with the SDK.
Installation
Add to your Cargo.toml:
[dependencies]
jetemail = "0.1"
tokio = { version = "1", features = ["full"] }
Crate on crates.io: jetemail.
Quick start
use jetemail::JetEmail;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = JetEmail::new("your-transactional-api-key");
let result = client.email().send(
jetemail::SendEmailOptions::builder()
.from("Your App <hello@yourdomain.com>")
.to("user@example.com")
.subject("Welcome!")
.html("<h1>Welcome!</h1>")
.build(),
).await?;
println!("{}", result.id);
Ok(())
}
Use a from address on a verified domain (see Getting started).
Constructor
// API key string
let client = JetEmail::new("your-transactional-api-key");
// Or with options
let client = JetEmail::builder()
.api_key("your-transactional-api-key")
.base_url("https://api.jetemail.com") // optional
.build();
client.email().send(options)
Send a single email.
| Field | Required | Description |
|---|
from | ✓ | Sender, e.g. "Name <email@domain.com>" |
to | ✓ | Recipient(s), string or vec (max 50) |
subject | ✓ | Subject line |
html | * | HTML body (need html and/or text) |
text | * | Plain text (need html and/or text) |
cc, bcc, reply_to | | Recipients (max 50 each) |
headers | | Custom headers HashMap |
attachments | | Attachments (max 40MB total) |
Response shape: SendEmailResponse { id: String, response: String }.
client.batch().send(emails)
Send up to 100 emails in one request. Returns summary (total, successful, failed) and results per message.
let result = client.batch().send(vec![
SendEmailOptions::builder()
.from("you@example.com")
.to("alice@example.com")
.subject("Hello Alice")
.html("<p>Hi Alice!</p>")
.build(),
SendEmailOptions::builder()
.from("you@example.com")
.to("bob@example.com")
.subject("Hello Bob")
.html("<p>Hi Bob!</p>")
.build(),
]).await?;
Attachments
use jetemail::Attachment;
let result = client.email().send(
SendEmailOptions::builder()
.from("you@example.com")
.to("recipient@example.com")
.subject("Invoice")
.html("<p>Please find your invoice attached.</p>")
.attachments(vec![
Attachment::from_path("/path/to/invoice.pdf").await?,
Attachment::from_content(b"Hello World", "hello.txt"),
])
.build(),
).await?;
Error handling
use jetemail::JetEmailError;
match client.email().send(options).await {
Ok(result) => println!("Sent: {}", result.id),
Err(JetEmailError::Api { status_code, message, response }) => {
eprintln!("{}: {}", status_code, message);
}
Err(e) => eprintln!("Error: {}", e),
}
Common status codes: 400 invalid request, 401 bad/missing API key, 500 server error.
For additional examples and the full option list, see the crates.io page. REST details: API reference.