Ship faster by treating email as code ๐
Website โข Get Your API Key โข Twitter
Templateless lets you generate and send transactional emails quickly and easily so you can focus on building your product.
It's perfect for SaaS, web apps, mobile apps, scripts and anywhere you have to send email programmatically.
- ๐ Anti drag-and-drop by design โ emails are a part of your code
- โ Components as code โ function calls turn into email HTML components
- ๐ป SDK for any language โ use your favorite programming language
- ๐ Meticulously tested โ let us worry about email client compatibility
- ๐ Use your favorite ESP โ Amazon SES, SendGrid, Mailgun + more
- ๐ช Email infrastructure โ rate-limiting, retries, scheduling + more
- โก Batch sending โ send 1 email or 1,000 with one API call
Use go get:
go get github.com/templateless/[email protected]
Then import the package into your own code:
import "github.com/templateless/templateless-go"
You'll need an API key for the example below โฌ๏ธ
- 3,000 emails per month
- All popular email provider integrations
- Start sending right away
This is all it takes to send a signup confirmation email:
package main
import (
"log"
"github.com/templateless/templateless-go"
)
func main() {
content, _ := templateless.NewContent().
Text("Hi, please **confirm your email**:").
Button("Confirm Email", "https://your-company.com/signup/confirm?token=XYZ").
Build()
emailAddress := templateless.NewEmailAddress("<YOUR_CUSTOMERS_EMAIL_ADDRESS>")
email, _ := templateless.NewEmail().
To(*emailAddress).
Subject("Confirm your signup ๐").
Content(*content).
Build()
templateless.NewTemplateless("<YOUR_API_KEY>").
Send(*email)
}
There are more Go examples in the examples folder โจ
Note
๐ง 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.
You can generate test API keys by activating the Test Mode in your dashboard. By using these keys, you'll be able to view your fully rendered emails without actually sending them.
When you use a test API key in your SDK, the following output will appear in your logs when you try to send an email:
Templateless [TEST MODE]: Emailed [email protected], preview: https://tmpl.sh/ATMxHLX4r9aE
The preview link will display the email, but you must be logged in to Templateless to view it.
Emails are crafted programmatically by making function calls. There's no dealing with HTML or drag-and-drop builders.
All of the following components can be mixed and matched to create dynamic emails:
Text / Markdown
Text component allow you to insert a paragraph. Each paragraph supports basic markdown:
-
Bold text:
**bold text**
-
Italic text:
_italic text_
-
Link:
[link text](https://example.com)
-
Also a link:
<https://example.com>
-
Headers (h1-h6):
# Big Header
###### Small Header
-
Unordered list:
- item one - item two - item three
-
Ordered list:
1. item one 1. item two 1. item three
templateless.NewContent().
Text("## Thank you for signing up").
Text("Please **verify your email** by [clicking here](https://example.com/confirm?token=XYZ)").
Build()
Link
Link component adds an anchor tag. This is the same as a text component with the link written in markdown:
templateless.NewContent().
Link("Confirm Email", "https://example.com/confirm?token=XYZ").
Build()
Button
Button can also be used as a call to action. Button color is set via your dashboard's app color.
templateless.NewContent().
Button("Confirm Email", "https://example.com/confirm?token=XYZ").
Build()
Image
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.
// Simple
templateless.NewContent().
Image("https://placekitten.com/300/200").
Build()
// Clickable & with attributes
url := "https://example.com"
width := 300
height := 200
alt := "Alt text"
templateless.NewContent().
Component(
components.NewImage(
"https://placekitten.com/300/200",
&url,
&width,
&height,
&alt,
),
).
Build()
Only the src
parameter is required; everything else is optional.
If you have "Image Optimization" turned on:
-
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.
-
Images will be converted into formats that are widely supported by email clients. The following image formats will be processed automatically:
- Jpeg
- Png
- Gif
- WebP
- Tiff
- Ico
- Bmp
- Svg
-
Maximum image size is 5MB for free accounts and 20MB for paid accounts.
-
You can specify
width
and/orheight
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.
One-Time Password
OTP component is designed for showing temporary passwords and reset codes.
templateless.NewContent().
Text("Here's your **temporary login code**:").
Otp("XY78-2BT0-YFNB-ALW9").
Build()
Social Icons
You can easily add social icons with links by simply specifying the username. Usually, this component is placed in the footer of the email.
These are all the supported platforms:
templateless.NewContent().
Socials([]components.SocialItem{
*components.NewSocialItem(components.Website, "https://example.com"),
*components.NewSocialItem(components.Email, "[email protected]"),
*components.NewSocialItem(components.Phone, "123-456-7890"), // `tel:` link
*components.NewSocialItem(components.Facebook, "Username"),
*components.NewSocialItem(components.YouTube, "ChannelID"),
*components.NewSocialItem(components.Twitter, "Username"),
*components.NewSocialItem(components.X, "Username"),
*components.NewSocialItem(components.GitHub, "Username"),
*components.NewSocialItem(components.Instagram, "Username"),
*components.NewSocialItem(components.LinkedIn, "Username"),
*components.NewSocialItem(components.Slack, "Org"),
*components.NewSocialItem(components.Discord, "Username"),
*components.NewSocialItem(components.TikTok, "Username"),
*components.NewSocialItem(components.Snapchat, "Username"),
*components.NewSocialItem(components.Threads, "Username"),
*components.NewSocialItem(components.Telegram, "Username"),
*components.NewSocialItem(components.Mastodon, "@[email protected]"),
*components.NewSocialItem(components.Rss, "https://example.com/blog"),
}).
Build()
View in Browser
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.
You can optionally provide the text for the link. If none is provided, default is used: "View in browser"
Anyone who knows the link will be able to see the email.
templateless.NewContent().
ViewInBrowser().
Build()
Store Badges
Link to your mobile apps via store badges:
templateless.NewContent().
StoreBadges([]components.StoreBadgeItem{
*components.NewStoreBadgeItem(components.AppStore, "https://apps.apple.com/us/app/example/id1234567890"),
*components.NewStoreBadgeItem(components.GooglePlay, "https://play.google.com/store/apps/details?id=com.example"),
*components.NewStoreBadgeItem(components.MicrosoftStore, "https://apps.microsoft.com/detail/example"),
}).
Build()
QR Code
You can also generate QR codes on the fly. They will be shown as images inside the email.
Here are all the supported data types:
// URL
templateless.NewContent().
QrCode("https://example.com").
Build()
// Email
templateless.NewContent().
Component(components.QrCodeEmail("[email protected]")).
Build()
// Phone
templateless.NewContent().
Component(components.QrCodePhone("123-456-7890")).
Build()
// SMS / Text message
templateless.NewContent().
Component(components.QrCodeSMS("123-456-7890")).
Build()
// Geo coordinates
templateless.NewContent().
Component(components.QrCodeCoordinates(37.773972, -122.431297)).
Build()
// Crypto address (for now only Bitcoin and Ethereum are supported)
templateless.NewContent().
Component(components.QrCodeCryptocurrencyAddress(components.Bitcoin, "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa")).
Build()
// You can also encode any binary data
templateless.NewContent().
Component(components.NewQrCode([]byte{1, 2, 3})).
Build()
Signature
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:
// Signature with a default font
templateless.NewContent().
Signature("John Smith").
Build()
// Signature with a custom font
templateless.NewContent().
Component(components.NewSignature("John Smith", &components.ReenieBeanie)).
Build()
These are the available fonts:
ReenieBeanie
preview โMeowScript
preview โCaveat
preview โZeyada
preview โPetemoss
preview โ
Signature should not exceed 64 characters. Only alphanumeric characters and most common symbols are allowed.
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).
header, _ := templateless.NewHeader(). // header of the email
Text("Smaller text").
Build()
content, _ := templateless.NewContent(). // body of the email
Text("Normal text").
Build()
Currently there are 2 themes to choose from: Unstyled
and Simple
content, _ := templateless.NewContent().
Theme(templateless.Simple).
Text("Hello world").
Build()
- Contributions are more than welcome
- Please star this repo for more visibility <3
-
For customer support feel free to email us at [email protected]
-
Have suggestions or want to give feedback? Here's how to reach us:
- For feature requests, please start a discussion
- Found a bug? Open an issue!
- Say hi @Templateless ๐