mailgen

Crates.iomailgen
lib.rsmailgen
version0.3.0
sourcesrc
created_at2022-11-12 19:35:00.695288
updated_at2024-05-09 19:42:32.279
descriptionMailgen generates clean, responsive HTML and Text e-mails for sending transactional mail
homepagehttps://github.com/atrox/mailgen
repositoryhttps://github.com/atrox/mailgen
max_upload_size
id713764
size70,260
Atrox (Atrox)

documentation

README

mailgen

Crates.io Documentation License

This crate allows you to generate pretty emails without all the hassle.

Inspired by the node.js package mailgen.

Examples

use mailgen::themes::DefaultTheme;
use mailgen::{Action, Branding, EmailBuilder, Greeting, Mailgen};

let theme = DefaultTheme::new();
let branding = Branding::new("test product", "https://testproduct.com");
let mailgen = Mailgen::new(&theme, branding);

let email = EmailBuilder::new()
    .greeting(Greeting::Name("person name"))
    .intro("test intro")
    .intro("another intro")
    .dictionary("test key", "test value")
    .dictionary("test key 2", "test value 2")
    .action(Action {
            text: "Test Action",
        link: "https://test.com/action",
        color: Some(("black", "white")),
        ..Default::default()
    })
    .action(Action {
            text: "Test Action 2",
        link: "https://test.com/action2",
        instructions: Some("test instruction"),
        ..Default::default()
    })
    .outro("test outr 1")
    .outro("test outro 2")
    .signature("test signature...")
    .build();

let rendered = mailgen.render_text(&email)?;
std::fs::write("./email.txt", &rendered)?;

let rendered = mailgen.render_html(&email)?;
std::fs::write("./email.html", &rendered)?;

default theme

Commit count: 26

cargo fmt