1 unstable release
Uses new Rust 2024
new 0.1.0 | Apr 6, 2025 |
---|
#13 in #sender
14KB
157 lines
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.
Dependencies
~12–22MB
~378K SLoC