#generate-html #generator #transactional #html-text #action #responsive

mailgen

Mailgen generates clean, responsive HTML and Text e-mails for sending transactional mail

9 releases

0.3.0 May 9, 2024
0.2.6 Apr 18, 2024
0.2.5 Jan 29, 2024
0.2.4 Aug 15, 2023
0.1.0 Nov 12, 2022

#106 in Email

Download history 4/week @ 2024-08-26 33/week @ 2024-09-02 15/week @ 2024-09-09 1/week @ 2024-09-16 37/week @ 2024-09-23 12/week @ 2024-09-30 23/week @ 2024-10-14 17/week @ 2024-10-21 7/week @ 2024-10-28 17/week @ 2024-11-11 29/week @ 2024-11-18

55 downloads per month

MIT license

40KB
319 lines

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

Dependencies

~0.4–6.5MB
~47K SLoC