You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+201-8Lines changed: 201 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,8 @@
23
23
24
24
[Templateless](https://templateless.com) lets you generate and send transactional emails quickly and easily so you can focus on building your product.
25
25
26
+
It's perfect for SaaS, web apps, mobile apps, scripts and anywhere you have to send email programmatically.
27
+
26
28
## ✨ Features
27
29
28
30
- 👋 **Anti drag-and-drop by design** — emails are a part of your code
@@ -47,6 +49,16 @@ Then import the package into your own code:
47
49
import"github.com/templateless/templateless-go"
48
50
```
49
51
52
+
## 🔑 Get Your API Key
53
+
54
+
You'll need an API key for the example below ⬇️
55
+
56
+
[](https://app.templateless.com/)
57
+
58
+
- 3,000 emails per month
59
+
- All popular email provider integrations
60
+
- Start sending right away
61
+
50
62
## 👩💻 Quick example
51
63
52
64
This is all it takes to send a signup confirmation email:
@@ -80,18 +92,199 @@ func main() {
80
92
}
81
93
```
82
94
83
-
> **Note**
84
-
> 🚧 **This SDK is not stable yet.** The API might change as more features are added. Please pay attention to the [CHANGELOG](CHANGELOG.md) for breaking changes.
95
+
There are more Go examples in the [examples](examples) folder ✨
96
+
97
+
> [!NOTE]
98
+
> 🚧 **The SDK is not stable yet.** This API might change as more features are added. Please watch the repo for the changes in the [CHANGELOG](CHANGELOG.md).
99
+
100
+
## 🔳 Components
101
+
102
+
Emails are crafted programmatically by making function calls. There's no dealing with HTML or drag-and-drop builders.
103
+
104
+
All of the following components can be mixed and matched to create dynamic emails:
105
+
106
+
<details>
107
+
<summary>Text / Markdown</summary>
108
+
109
+
Text component allow you to insert a paragraph. Each paragraph supports basic markdown:
110
+
111
+
- Bold text: `**bold text**`
112
+
- Italic text: `_italic text_`
113
+
- Link: `[link text](https://example.com)`
114
+
- Also a link: `<https://example.com>`
115
+
- Headers (h1-h6):
116
+
117
+
-`# Big Header`
118
+
-`###### Small Header`
119
+
120
+
- Unordered list:
121
+
122
+
```md
123
+
- item one
124
+
- item two
125
+
- item three
126
+
```
127
+
128
+
- Ordered list:
129
+
130
+
```md
131
+
1. item one
132
+
1. item two
133
+
1. item three
134
+
```
135
+
136
+
```go
137
+
templateless.NewContent().
138
+
Text("## Thank you for signing up").
139
+
Text("Please **verify your email** by [clicking here](https://example.com/confirm?token=XYZ)").
140
+
Build()
141
+
```
142
+
143
+
</details>
144
+
<details><summary>Link</summary>
145
+
146
+
Link component adds an anchor tag. This is the same as a text component with the link written in markdown:
Image component will link to an image within your email. Keep in mind that a lot of email clients will prevent images from being loaded automatically for privacy reasons.
170
+
171
+
```go
172
+
templateless.NewContent().
173
+
Image(
174
+
"https://placekitten.com/300/200", // where the image is hosted
175
+
"https://example.com", // [optional] link url, if you want it to be clickable
176
+
300, // [optional] width
177
+
200, // [optional] height
178
+
"Alt text", // [optional] alternate text
179
+
).
180
+
Build()
181
+
```
182
+
183
+
Only the `src` parameter is required; everything else is optional.
184
+
185
+
**If you have "Image Optimization" turned on:**
186
+
187
+
1. Your images will be cached and distributed by our CDN for faster loading. The cache does not expire. If you'd like to re-cache, simply append a query parameter to the end of your image url.
188
+
1. Images will be converted into formats that are widely supported by email clients. The following image formats will be processed automatically:
189
+
190
+
- Jpeg
191
+
- Png
192
+
- Gif
193
+
- WebP
194
+
- Tiff
195
+
- Ico
196
+
- Bmp
197
+
- Svg
198
+
199
+
1. Maximum image size is 5MB for free accounts and 20MB for paid accounts.
200
+
1. You can specify `width` and/or `height` if you'd like (they are optional). Keep in mind that images will be scaled down to fit within the email theme, if they're too large.
201
+
202
+
</details>
203
+
<details><summary>One-Time Password</summary>
204
+
205
+
OTP component is designed for showing temporary passwords and reset codes.
206
+
207
+
```go
208
+
templateless.NewContent().
209
+
Text("Here's your **temporary login code**:").
210
+
Otp("XY78-2BT0-YFNB-ALW9").
211
+
Build()
212
+
```
213
+
214
+
</details>
215
+
<details><summary>Social Icons</summary>
216
+
217
+
You can easily add social icons with links by simply specifying the username. Usually, this component is placed in the footer of the email.
If you'd like your recipients to be able to read the email in a browser, you can add the "view in browser" component that will automatically generate a link. Usually, this is placed in the header or footer of the email.
248
+
249
+
You can optionally provide the text for the link. If none is provided, default is used: "View in browser"
85
250
86
-
Examples:
251
+
**This will make the email public to anyone that has access to the link.**
252
+
253
+
```go
254
+
templateless.NewContent().
255
+
ViewInBrowser("Read Email in Browser").
256
+
Build()
257
+
```
258
+
259
+
</details>
260
+
261
+
---
87
262
88
-
1. Get your **free API key** here: <https://app.templateless.com> ✨
89
-
1. There are more Go examples in the [examples](examples) folder
263
+
Components can be placed in the header, body and footer of the email. Header and footer styling is usually a bit different from the body (for example the text is smaller).
264
+
265
+
```go
266
+
header, _:= templateless.NewHeader(). // header of the email
267
+
Text("Smaller text").
268
+
Build()
269
+
270
+
content, _:= templateless.NewContent(). // body of the email
271
+
Text("Normal text").
272
+
Build()
273
+
```
274
+
275
+
Currently there are 2 themes to choose from: `Unstyled` and `Simple`
276
+
277
+
```go
278
+
content, _:= templateless.NewContent().
279
+
Theme(templateless.Simple).
280
+
Text("Hello world").
281
+
Build()
282
+
```
90
283
91
284
## 🤝 Contributing
92
285
93
-
- Contributions are more than welcome <3
94
-
- Please **star this repo** for more visibility ★
286
+
- Contributions are more than welcome
287
+
- Please **star this repo** for more visibility <3
95
288
96
289
## 📫 Get in touch
97
290
@@ -101,7 +294,7 @@ Examples:
101
294
102
295
- For feature requests, please [start a discussion](https://github.com/templateless/templateless-go/discussions)
103
296
- Found a bug? [Open an issue!](https://github.com/templateless/templateless-go/issues)
104
-
-We are also on Twitter: [@Templateless](https://twitter.com/templateless)
297
+
-Say hi [@Templateless](https://twitter.com/templateless) 👋
0 commit comments