https://github.com/atrox/mailgen
Mailgen: Rust crate that generates clean, responsive HTML and text e-mails for sending transactional mail
https://github.com/atrox/mailgen
mailgen rust
Last synced: 9 months ago
JSON representation
Mailgen: Rust crate that generates clean, responsive HTML and text e-mails for sending transactional mail
- Host: GitHub
- URL: https://github.com/atrox/mailgen
- Owner: Atrox
- License: mit
- Created: 2022-11-12T19:34:03.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-08-19T04:56:18.000Z (over 1 year ago)
- Last Synced: 2025-04-12T21:46:49.829Z (9 months ago)
- Topics: mailgen, rust
- Language: Rust
- Homepage:
- Size: 71.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mailgen
[](https://crates.io/crates/mailgen)
[](https://docs.rs/mailgen)
[](LICENSE)
This crate allows you to generate pretty emails without all the hassle.
Inspired by the node.js package [mailgen](https://github.com/eladnava/mailgen).
# Examples
```rust
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)?;
```
