@@ -40,7 +40,7 @@ It's perfect for SaaS, web apps, mobile apps, scripts and anywhere you have to s
40
40
Use go get:
41
41
42
42
``` bash
43
- go get github.com/templateless/
[email protected] .
3
43
+ go get github.com/templateless/
[email protected] .
4
44
44
```
45
45
46
46
Then import the package into your own code:
@@ -85,10 +85,8 @@ func main() {
85
85
Content (*content).
86
86
Build ()
87
87
88
- result , _ := templateless.NewTemplateless (" <YOUR_API_KEY>" ).
88
+ templateless.NewTemplateless (" <YOUR_API_KEY>" ).
89
89
Send (*email)
90
-
91
- log.Println (result)
92
90
}
93
91
```
94
92
@@ -159,8 +157,7 @@ Link component adds an anchor tag. This is the same as a text component with the
159
157
160
158
``` go
161
159
templateless.NewContent ().
162
- Link (" Confirm Email" , " https://example.com/confirm?token=XYZ" ). // or...
163
- Text (" [Confirm Email](https://example.com/confirm?token=XYZ)" ).
160
+ Link (" Confirm Email" , " https://example.com/confirm?token=XYZ" ).
164
161
Build ()
165
162
```
166
163
@@ -181,13 +178,25 @@ templateless.NewContent().
181
178
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.
182
179
183
180
``` go
181
+ // Simple
182
+ templateless.NewContent ().
183
+ Image (" https://placekitten.com/300/200" ).
184
+ Build ()
185
+
186
+ // Clickable & with attributes
187
+ url := " https://example.com"
188
+ width := 300
189
+ height := 200
190
+ alt := " Alt text"
184
191
templateless.NewContent ().
185
- Image (
186
- " https://placekitten.com/300/200" , // where the image is hosted
187
- " https://example.com" , // [optional] link url, if you want it to be clickable
188
- 300 , // [optional] width
189
- 200 , // [optional] height
190
- " Alt text" , // [optional] alternate text
192
+ Component (
193
+ components.NewImage (
194
+ " https://placekitten.com/300/200" ,
195
+ &url,
196
+ &width,
197
+ &height,
198
+ &alt,
199
+ ),
191
200
).
192
201
Build ()
193
202
```
@@ -249,6 +258,8 @@ templateless.NewContent().
249
258
*components.NewSocialItem (components.Snapchat , " Username" ),
250
259
*components.NewSocialItem (components.Threads , " Username" ),
251
260
*components.NewSocialItem (components.Telegram , " Username" ),
261
+ *components.
NewSocialItem (components.
Mastodon ,
" @[email protected] " ),
262
+ *components.NewSocialItem (components.Rss , " https://example.com/blog" ),
252
263
}).
253
264
Build ()
254
265
```
@@ -264,11 +275,98 @@ You can optionally provide the text for the link. If none is provided, default i
264
275
265
276
``` go
266
277
templateless.NewContent ().
267
- ViewInBrowser (" Read Email in Browser" ).
278
+ ViewInBrowser ().
279
+ Build ()
280
+ ```
281
+
282
+ </details >
283
+ <details ><summary >Store Badges</summary >
284
+
285
+ Link to your mobile apps via store badges:
286
+
287
+ ``` go
288
+ templateless.NewContent ().
289
+ StoreBadges ([]components.StoreBadgeItem {
290
+ *components.NewStoreBadgeItem (components.AppStore , " https://apps.apple.com/us/app/example/id1234567890" ),
291
+ *components.NewStoreBadgeItem (components.GooglePlay , " https://play.google.com/store/apps/details?id=com.example" ),
292
+ *components.NewStoreBadgeItem (components.MicrosoftStore , " https://apps.microsoft.com/detail/example" ),
293
+ }).
268
294
Build ()
269
295
```
270
296
271
297
</details >
298
+ <details ><summary >QR Code</summary >
299
+
300
+ You can also generate QR codes on the fly. They will be shown as images inside the email.
301
+
302
+ Here are all the supported data types:
303
+
304
+ ``` go
305
+ // URL
306
+ templateless.NewContent ().
307
+ QrCode (" https://example.com" ).
308
+ Build ()
309
+
310
+ // Email
311
+ templateless.NewContent ().
312
+ Component (components.
QrCodeEmail (
" [email protected] " )).
313
+ Build ()
314
+
315
+ // Phone
316
+ templateless.NewContent ().
317
+ Component (components.QrCodePhone (" 123-456-7890" )).
318
+ Build ()
319
+
320
+ // SMS / Text message
321
+ templateless.NewContent ().
322
+ Component (components.QrCodeSMS (" 123-456-7890" )).
323
+ Build ()
324
+
325
+ // Geo coordinates
326
+ templateless.NewContent ().
327
+ Component (components.QrCodeCoordinates (37.773972 , -122.431297 )).
328
+ Build ()
329
+
330
+ // Crypto address (for now only Bitcoin and Ethereum are supported)
331
+ templateless.NewContent ().
332
+ Component (components.QrCodeCryptocurrencyAddress (components.Bitcoin , " 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa" )).
333
+ Build ()
334
+
335
+ // You can also encode any binary data
336
+ templateless.NewContent ().
337
+ Component (components.NewQrCode ([]byte {1 , 2 , 3 })).
338
+ Build ()
339
+ ```
340
+
341
+ </details >
342
+ <details ><summary >Signature</summary >
343
+
344
+ Generated signatures can be added to your emails to give a bit of a personal touch. This will embed an image with your custom text using one of several available fonts:
345
+
346
+ ``` go
347
+ // Signature with a default font
348
+ templateless.NewContent ().
349
+ Signature (" John Smith" ).
350
+ Build ()
351
+
352
+ // Signature with a custom font
353
+ templateless.NewContent ().
354
+ Component (components.NewSignature (" John Smith" , &components.ReenieBeanie )).
355
+ Build ()
356
+ ```
357
+
358
+ These are the available fonts:
359
+
360
+ - ` ReenieBeanie ` [ preview →] ( https://fonts.google.com/specimen/Reenie+Beanie )
361
+ - ` MeowScript ` [ preview →] ( https://fonts.google.com/specimen/Meow+Script )
362
+ - ` Caveat ` [ preview →] ( https://fonts.google.com/specimen/Caveat )
363
+ - ` Zeyada ` [ preview →] ( https://fonts.google.com/specimen/Zeyada )
364
+ - ` Petemoss ` [ preview →] ( https://fonts.google.com/specimen/Petemoss )
365
+
366
+ Signature should not exceed 64 characters. Only alphanumeric characters and most common symbols are allowed.
367
+
368
+ </details >
369
+
272
370
273
371
---
274
372
0 commit comments