kannon_mail

Crates.iokannon_mail
lib.rskannon_mail
version0.1.0
created_at2025-04-06 08:27:51.75887+00
updated_at2025-04-06 08:27:51.75887+00
descriptionRust client library for kannon.email
homepage
repositoryhttps://github.com/marcobacis/kannon.rs
max_upload_size
id1622717
size44,779
Marco Bacis (marcobacis)

documentation

README

kannon.rs: unofficial Rust client library for Kannon Email Sender

kannon_mail is the (unofficial) Rust client library for Kannon.

Usage

First, instantiate the Kannon client

let sender = Sender {
    email: "sender@kannon.dev".into(),
    alias: "Kannon".into(),
};

let mut kannon = Kannon::new(
    "<YOUR DOMAIN>".into(),
    "<YOUR KEY>".into(),
    sender,
    "<YOUR KANNON API HOST>".into(),
)
.await?;

[!NOTE] Remember to add https:// to the API host (e.g. https://grpc.kannon.email:443)! Also, the sender email should be part of your domain

To send mails, use the send_mail method:

let recipients = vec![Recipient {
    email: "test@mail.com".into(),
    fields: HashMap::from([("name".into(), "Test".into())]),
}];

kannon.send_email(
    recipients,
    "Hello from Kannon".into(), // Subject
    "<body>Hello from Kannon, {{ name }}!!</body>".into(), // Html Body
    vec![] // Attachments
)
.await?;

Sending Templates

Similar to mails, you can send templates by indicating the template id instead of the mail body:

kannon.send_template(
    recipients,
    "Hello from Kannon".into(),
    "<template-id>".into(),
    vec![]
)
.await?;

Credits

Developed (together with @ludusrusso] during Open Source Saturday Milan.

Open Source Saturday

Commit count: 6

cargo fmt