Skip to content

Commit 163fb98

Browse files
committed
docs: updated docs
1 parent 2c062b9 commit 163fb98

File tree

6 files changed

+116
-49
lines changed

6 files changed

+116
-49
lines changed

README.md

Lines changed: 116 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,69 @@
55
[![Build Status](https://travis-ci.com/rocketbase-io/email-template-builder.svg?branch=master)](https://travis-ci.com/rocketbase-io/email-template-builder)
66
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.rocketbase.commons/email-template-builder/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.rocketbase.commons/email-template-builder)
77

8-
Let this service build your html/text emails in a fluient manner. It doesn't try to reinvent the wheel - it simply extends the given [email-template](https://github.com/mailgun/transactional-email-templates) of mailgun and backed it for java to use it for many purposes.
8+
Let this service build your html/text emails in a fluent manner. It doesn't try to reinvent the wheel - it simply extends the given [email-template](https://postmarkapp.com/mailmason) of postmark and backed it for java to use it for many purposes.
99

1010
You can write your email content fluently and the template builder cares for the correct instyling, conversation to txt version etc...
1111

12-
For sending the email I can recommend the spring-boot-starter-mail or simplejavamail...
12+
For sending the email I can recommend the spring-boot-starter-mail, simplejavamail or my [postmark-spring](https://github.com/rocketbase-io/postmark-spring)...
13+
14+
### release notes
15+
- 1.x bases mailgun templates
16+
- extra dependency on jsoup for auto inlining/transpiling to text
17+
- doc for old api could be found in wiki
18+
19+
- 2.x bases on new postmark templates
20+
- pom artifact group changed to **io.rocketbase.mail**
21+
- removed jsoup from dependency and changed api in many cases
22+
- cleaned up a lot of code
23+
- separated module in two pices
24+
- common builder
25+
- markdown (with markdown support)
1326

1427
## features
1528

1629
- generate html and text mail via one fluent build
17-
- just a few dependencies: jsoup + pebble-template engine
30+
- just pebble-template engine as dependency
1831
- support for the following content-types
1932
- Logo in the header
20-
- Header with custom Styling
2133
- Text also with HTML support and Alignment configuration
2234
- Image with Alignment configuration and Link options
2335
- Button with custom Styling
2436
- Footer with HTML support and Alignment configuration
2537
- Copyright with dynamic Year and Link options
2638
- table with header, item/price, total
39+
- key value pairs
40+
- interface for tables to provide custom layouts
41+
- extra module to transpile markdown
2742

2843
## usage
2944

3045
## sample html/text
3146
```java
3247
// generate html/text content
33-
HtmlTextEmail htmlTextEmail = EmailTemplateBuilder.builder()
34-
.logo("https://cdn.rocketbase.io/assets/signature/rocketbase-signature-20179.png", "rocketbase-logo", 250, 50).title("visit rocketbase.io").linkUrl("https://www.rocketbase.io").and()
35-
.header("Warning: You're approaching your limit").color(new ColorStyle("ffffff", "ff9f00")).and()
36-
.addText("You have 1 <b>free report</b> remaining.").and()
37-
.addText("Add your credit card now to upgrade your account to a premium plan to ensure you don't miss out on any reports.").and()
38-
.addButton("Upgrade My Account", "http//upgrade").color(new ColorStyle("ffffff", "348eda")).center().and()
39-
.addText("Thanks for choosing Acme Inc.").and()
40-
.addText("<i>Ps. This email has been build with template-builder</i>").center().and()
41-
.addImage("https://assets-cdn.github.com/images/modules/logos_page/GitHub-Logo.png", "rocketbase-io/email-template-builder", 250, 65).center().title("link to github project").linkUrl("https://github.com/rocketbase-io/email-template-builder").and()
42-
.addText("<strong><i>Cheers your rocketbase-team</i></strong>").center().and()
43-
.addFooter("<a href=\"http://unsubscribe\">Unsubscribe</a> from these alerts.").and()
44-
.copyright("rocketbase.io").url("https://www.rocketbase.io")
45-
.build();
48+
HtmlTextEmail htmlTextEmail = builder
49+
.header()
50+
.logo("https://www.rocketbase.io/img/logo-dark.png").logoHeight(41)
51+
.and()
52+
.text("Welcome, {{name}}!").h1().center().and()
53+
.text("Thanks for trying [Product Name]. We’re thrilled to have you on board. To get the most out of [Product Name], do this primary next step:").and()
54+
.button("Do this Next", "http://localhost").blue().and()
55+
.text("For reference, here's your login information:").and()
56+
.attribute()
57+
.keyValue("Login Page", "{{login_url}}")
58+
.keyValue("Username", "{{username}}")
59+
.and()
60+
.html("If you have any questions, feel free to <a href=\"mailto:{{support_email}}\">email our customer success team</a>. (We're lightning quick at replying.) We also offer <a href=\"{{live_chat_url}}\">live chat</a> during business hours.",
61+
"If you have any questions, feel free to email our customer success team\n" +
62+
"(We're lightning quick at replying.) We also offer live chat during business hours.").and()
63+
.text("Cheers,\n" +
64+
"The [Product Name] Team").and()
65+
.copyright("rocketbase").url("https://www.rocketbase.io").suffix(". All rights reserved.").and()
66+
.footerText("[Company Name, LLC]\n" +
67+
"1234 Street Rd.\n" +
68+
"Suite 1234").and()
69+
.footerImage("https://cdn.rocketbase.io/assets/loading/no-image.jpg").width(100).linkUrl("https://www.rocketbase.io").and()
70+
.build();
4671

4772
// sent email
4873
MimeMessage message = emailSender.createMimeMessage();
@@ -59,52 +84,94 @@ emailSender.send(message);
5984

6085
### preview HTML-Version
6186

62-
![sample](assets/mail-sample.png)
87+
![sample](assets/v2-mail-sample.png)
6388

6489
### preview Text-Version
6590

6691
```
67-
Warning: You're approaching your limit
68-
You have 1 free report remaining.
69-
Add your credit card now to upgrade your account to a premium plan to ensure you don't miss out on any reports.
70-
Upgrade My Account -> http//upgrade
71-
Thanks for choosing Acme Inc.
72-
Ps. This email has been build with template-builder
73-
74-
Cheers your rocketbase-team
75-
Unsubscribe -> http://unsubscribe from these alerts.
76-
2018 rocketbase.io -> https://www.rocketbase.io
77-
```
92+
Welcome, {{name}}!
93+
94+
Thanks for trying [Product Name]. We=E2=80=99re thrilled to have you on boa=
95+
rd. To get the most out of [Product Name], do this primary next step:
7896
97+
Do this Next -> http://localhost
98+
99+
For reference, here's your login information:
100+
101+
Login Page: {{login_url}}
102+
Username: {{username}}
103+
104+
105+
If you have any questions, feel free to email our customer success team
106+
(We're lightning quick at replying.) We also offer live chat during business hours.
107+
108+
Cheers,
109+
The [Product Name] Team
110+
```
79111

80-
[Email-on-acid-report](https://app.emailonacid.com/app/acidtest/ObQRaQOYKG17yavB6MUHxXXfujAASn6v9iK3JSwFpSteP/list)
81112

82113
### sample table
83114
```java
115+
TbConfiguration config = TbConfiguration.newInstance();
116+
config.getContent().setFull(true);
117+
84118
HtmlTextEmail htmlTextEmail = builder
85-
.header(header).and()
86-
.addText("Ihre Bestellung wurde geprüft und wird im nächsten Schritt verpackt.").and()
87-
88-
.addTable()
89-
.addHeader("Bestellnr.: #12345<br>Datum: Februar 04 2020", true, Alignment.RIGHT)
90-
.addItemRowWithPrefixMiddle("Menge", "Produkt", "Mwst", "Preis").headerRow().nextRow()
91-
.addItemRowWithPrefixMiddle(3, "Bandnudel", "19%", BigDecimal.valueOf(1320, 2)).nextRow()
92-
.addItemRowWithPrefixMiddle(2, "Ravioli", "7%", BigDecimal.valueOf(1040, 2)).nextRow()
93-
.addItemRowWithPrefixMiddle(1, "Spaghetti Sack", "19%", BigDecimal.valueOf(2755, 2)).nextRow()
94-
.addTotalRow(BigDecimal.valueOf(5115, 2)).totalCaption("Zwischensumme netto").borderBottom(false).nextRow()
95-
.addTotalRow(BigDecimal.valueOf(73, 2)).totalCaption("zzgl. MwSt. 7%").borderTop(false).borderBottom(false).nextRow()
96-
.addTotalRow(BigDecimal.valueOf(774, 2)).totalCaption("zzgl. MwSt. 19%").borderTop(false).borderBottom(false).nextRow()
97-
.addTotalRow(BigDecimal.valueOf(5115 + 73 + 774, 2)).totalCaption("Rechnungsbetrag").borderTop(false)
119+
.configuration(config)
120+
.header().text(header).and()
121+
.text("Hi {{name}},").and()
122+
.text("Thanks for using [Product Name]. This is an invoice for your recent purchase").and()
123+
.tableSimple("#.## '€'")
124+
.headerRow("Description", "Amount")
125+
.itemRow("Special Product\n" +
126+
"Some extra explanations in separate line", BigDecimal.valueOf(1333, 2))
127+
.itemRow("Short service", BigDecimal.valueOf(103, 1))
128+
.footerRow("Total", BigDecimal.valueOf(2363, 2))
129+
.and()
130+
.button("Download PDF", "http://localhost").gray().right().and()
131+
.text("If you have any questions about this receipt, simply reply to this email or reach out to our support team for help.").and()
132+
.copyright("rocketbase").url("https://www.rocketbase.io").suffix(". All rights reserved.").and()
133+
.footerText("[Company Name, LLC]\n" +
134+
"1234 Street Rd.\n" +
135+
"Suite 1234").and()
136+
.build();
137+
```
138+
139+
### preview HTML-Version
98140

141+
![sample-table](assets/v2-mail-sample-table.png)
142+
143+
### sample table with image
144+
145+
```java
146+
TbConfiguration config = TbConfiguration.newInstance();
147+
config.getContent().setWidth(800);
148+
149+
HtmlTextEmail htmlTextEmail = builder
150+
.configuration(config)
151+
.header().text(header).and()
152+
.text("Hi {{name}},").and()
153+
.text("Thanks for using [Product Name]. This is an invoice for your recent purchase").and()
154+
.tableSimpleWithImage("#.## '€'")
155+
.headerRow("Preview", "Description", "Amount")
156+
.itemRow("https://cdn.shopify.com/s/files/1/0255/1211/6260/products/TCW1142-07052_small.jpg?v=1589200198", "Damen Harbour Tanktop × 1\n" +
157+
"QUARTZ PINK / S", BigDecimal.valueOf(4995, 2))
158+
.itemRow("https://cdn.shopify.com/s/files/1/0255/1211/6260/products/TCM1886-0718_201_fdf0be52-639f-4ea8-9143-6bd75e0821b1_small.jpg?v=1583509609", "Herren ten Classic T-Shirt\n"+
159+
"FOREST GREEN HEATHER / XL", BigDecimal.valueOf(3995, 2))
160+
.itemRow("https://cdn.shopify.com/s/files/1/0255/1211/6260/products/TCM1939-0439_1332_da6f3e7c-e18d-4778-be97-c6c0b482b643_small.jpg?v=1583509671", "Herren Joshua Hanfshorts\n" +
161+
"DARK OCEAN BLUE / XL", BigDecimal.valueOf(6995, 2))
162+
.footerRow("Sum", BigDecimal.valueOf(15985, 2))
163+
.footerRow("Code - PLANT5", BigDecimal.valueOf(-799, 2))
164+
.footerRow("Total incl. Tax\n", BigDecimal.valueOf(15186, 2))
99165
.and()
100-
.addText("Vielen Dank für Ihren Auftrag").and()
101-
.addButton("Link zur Bestellhistorie", "http://adasd").and()
102-
.addText("Freundliche Grüße,").and()
103-
.addText("Team XYZ").and()
104-
.copyright("rocketbase").url("https://www.rocketbase.io")
166+
.button("Download PDF", "http://localhost").gray().right().and()
167+
.text("If you have any questions about this receipt, simply reply to this email or reach out to our support team for help.").and()
168+
.copyright("rocketbase").url("https://www.rocketbase.io").suffix(". All rights reserved.").and()
169+
.footerText("[Company Name, LLC]\n" +
170+
"1234 Street Rd.\n" +
171+
"Suite 1234").and()
105172
.build();
106173
```
107174

108175
### preview HTML-Version
109176

110-
![sample-table](assets/mail-sample-table.png)
177+
![sample-table](assets/v2-mail-sample-table-image.png)
File renamed without changes.
File renamed without changes.

assets/v2-mail-sample-table-image.png

47.1 KB
Loading

assets/v2-mail-sample-table.png

34.9 KB
Loading

assets/v2-mail-sample.png

40.7 KB
Loading

0 commit comments

Comments
 (0)