| Crates.io | kannon_mail |
| lib.rs | kannon_mail |
| version | 0.1.0 |
| created_at | 2025-04-06 08:27:51.75887+00 |
| updated_at | 2025-04-06 08:27:51.75887+00 |
| description | Rust client library for kannon.email |
| homepage | |
| repository | https://github.com/marcobacis/kannon.rs |
| max_upload_size | |
| id | 1622717 |
| size | 44,779 |
kannon_mail is the (unofficial) Rust client library for Kannon.
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?;
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?;
Developed (together with @ludusrusso] during Open Source Saturday Milan.