resend_email_rs

Crates.ioresend_email_rs
lib.rsresend_email_rs
version0.1.0
sourcesrc
created_at2024-04-26 00:04:44.412403
updated_at2024-04-26 00:04:44.412403
descriptionLightweight mailing SDK for Resend.com
homepage
repositoryhttps://github.com/floris-xlx/resend_email_rs
max_upload_size
id1220824
size50,593
Floris (floris-xlx)

documentation

README

Resend Email Library

The Resend Email Library provides comprehensive solutions for email operations within Rust applications. This crate supports various email functionalities, including plain text and HTML emails, and facilitates handling attachments.

Coming soon

I will add the bulk emailing method soon :)

Getting Started

To use the Resend Email Library, add it to your Cargo.toml:

[dependencies]
resend_rs = "0.1.0"

Features

Examples

Here are examples of how to send different types of emails using this library:

Authenticating the client

use resend_rs::ResendClient;

let client = ResendClient::new("your_auth_token".to_string());

Make sure to replace your_auth_token with your actual Resend API token.

Sending a Plain Text Email

use resend_rs::{ResendClient, MailText};

let client = ResendClient::new("your_auth_token".to_string());

let mail = MailText {
    from: "floris@xylex.ai",
    to: vec!["recipient@example.com"],
    subject: "Test Email",
    text: "Hello, this is a test email.",
    attachments: None,
};
let email_sent_status: Email = client.send(&mail).await.unwrap();

Sending an HTML Email

use resend_rs::{ResendClient, MailHtml};

let client = ResendClient::new("your_auth_token".to_string());
let mail = MailHtml {
    from: "floris@xylex.ai",
    to: vec!["recipient@example.com"],
    subject: "Hello World",
    html: "<h1>Welcome</h1><p>This is an HTML email.</p>",
    attachments: None,
};
let email_sent_status: Email = client.send(&mail).await.unwrap();

Sending an Email with Attachments

use resend_rs::{ResendClient, MailText, Attachment};

let client = ResendClient::new("your_auth_token".to_string());
let attachment = Attachment {
    content: vec![0, 1, 2, 3],
    filename: "example.txt",
};
let mail = MailText {
    from: "floris@xylex.ai",
    to: vec!["recipient@example.com"],
    subject: "Test Email with Attachment",
    text: "Please find the attachment.",
    attachments: Some(vec![attachment]),
};
let email_sent_status: Email = client.send(&mail).await.unwrap();

Handling Success and Errors

The library provides detailed feedback for operations:

Every email send operation returns a Result<Email, Error> indicating the outcome, which makes it easy to handle success or diagnose issues programmatically.

Commit count: 3

cargo fmt