Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stardogventures/templatemail
Template-based email library for Java 8
https://github.com/stardogventures/templatemail
amazon-ses email email-template handlebars java java-8 mailgun sailthru ses
Last synced: 2 months ago
JSON representation
Template-based email library for Java 8
- Host: GitHub
- URL: https://github.com/stardogventures/templatemail
- Owner: stardogventures
- License: apache-2.0
- Created: 2016-11-09T09:51:18.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-16T21:47:13.000Z (over 6 years ago)
- Last Synced: 2024-11-14T13:44:37.443Z (2 months ago)
- Topics: amazon-ses, email, email-template, handlebars, java, java-8, mailgun, sailthru, ses
- Language: Java
- Homepage:
- Size: 54.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# templatemail
A simple template-based email library for Java 8.
Applications often need to send transactional emails, such as welcomes, notifications, and password resets. This simple library implements an `TemplateEmailer` class which abstracts out the email service, allowing your code to easily send templates without worrying about the underlying implementation.
Currently supported services:
* [Amazon SES](https://aws.amazon.com/ses/)
* [Sailthru](https://getstarted.sailthru.com/)
* [Mailgun](https://www.mailgun.com/)
* Basic SMTP for testing using [MailCatcher](https://mailcatcher.me)(Full disclosure: The library author is the former CTO of Sailthru, so these are the services I personally like and use. But happy to accept contributions for other email services.)
For Amazon SES and Mailgun, email templates are stored locally, using [Handlebars](http://handlebarsjs.com/) templates. Sailthru hosts email templates on the service, so templates do not need to be maintained locally.
## Maven Installation
Add the following dependency to your POM file:
```
io.stardog
templatemail
0.7.1```
## Example Usage
```java
AmazonSimpleEmailServiceClient sesClient = new AmazonSimpleEmailServiceClient();
TemplateEmailer emailer = new AmazonSesEmailer(sesClient);// add any number of global variables. These vars will be passed to every template automatically
emailer.putGlobalVar("MY_GLOBAL_VAR", "MY_GLOBAL_VALUE");// add any number of templates
emailer.addTemplate(EmailTemplate.builder()
.templateName("welcome")
.fromEmail("[email protected]")
.fromName("Example Name")
.subject("Welcome, {{name}}!")
.contentHtml("Welcome to our service, {{name}}. Var: {{myvar}}
")
.build());
// send a template
Map vars = new HashMap<>();
vars.put("myvar", "var value");
emailer.sendTemplate("welcome", "[email protected]", "User Name", vars);
```