Code Monkey home page Code Monkey logo

mailgen's Introduction

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

mailgen's People

Contributors

atrox avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.