org.sevensource.commons:html-email-service

Library for creating and sending HTML email with Spring. Contains functionality to transform text to html, as well as html to text.

License

License

GroupId

GroupId

org.sevensource.commons
ArtifactId

ArtifactId

html-email-service
Last Version

Last Version

0.4.0
Release Date

Release Date

Type

Type

jar
Description

Description

Library for creating and sending HTML email with Spring. Contains functionality to transform text to html, as well as html to text.
Project URL

Project URL

http://www.sevensource.org/
Project Organization

Project Organization

SevenSource
Source Code Management

Source Code Management

http://github.com/sevensource/html-email-service

Download html-email-service

How to add to project

<!-- https://jarcasting.com/artifacts/org.sevensource.commons/html-email-service/ -->
<dependency>
    <groupId>org.sevensource.commons</groupId>
    <artifactId>html-email-service</artifactId>
    <version>0.4.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.sevensource.commons/html-email-service/
implementation 'org.sevensource.commons:html-email-service:0.4.0'
// https://jarcasting.com/artifacts/org.sevensource.commons/html-email-service/
implementation ("org.sevensource.commons:html-email-service:0.4.0")
'org.sevensource.commons:html-email-service:jar:0.4.0'
<dependency org="org.sevensource.commons" name="html-email-service" rev="0.4.0">
  <artifact name="html-email-service" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.sevensource.commons', module='html-email-service', version='0.4.0')
)
libraryDependencies += "org.sevensource.commons" % "html-email-service" % "0.4.0"
[org.sevensource.commons/html-email-service "0.4.0"]

Dependencies

compile (8)

Group / Artifact Type Version
org.springframework : spring-context-support jar 4.0.6.RELEASE
javax.enterprise : cdi-api jar 1.2
org.thymeleaf : thymeleaf jar 2.1.3.RELEASE
org.thymeleaf : thymeleaf-spring4 jar 2.1.3.RELEASE
net.htmlparser.jericho : jericho-html jar 3.3
org.apache.commons : commons-lang3 jar 3.3.2
joda-time : joda-time jar 2.3
org.slf4j : slf4j-api jar 1.7.7

provided (1)

Group / Artifact Type Version
javax.mail : mail jar 1.4.7

Project Modules

There are no modules declared in this project.

GitHub Tag Maven Central License Build Status

html-email-service

Wrapper library for creating and sending HTML email with Spring.

  • uses Thymeleaf for templating
  • transforms text to html
  • transforms html to text
  • attachments (inline and attachment)

Example

<dependency>
	<groupId>org.sevensource.mail</groupId>
	<artifactId>html-email-service</artifactId>
	<version>${the.version}</version>
</dependency>
@Configuration
public class EmailServiceConfiguration {
	@Autowired
	ApplicationContext applicationContext;
	
	// also see ConfigurableJavaMailSenderConfiguration
	@Autowired 
	JavaMailSender javaMailSender;
	
	@Bean
	public EmailTemplateRendererService emailTemplateRenderService() {
		return new EmailTemplateRendererService(factory);
	}
	
	@Bean
	public EmailSenderService emailSenderService() {
		TemplateEngineFactory factory = new DefaultTemplateEngineFactory(applicationContext);
		return new EmailTemplateRendererService(factory);
	}
}
public void sendmail() {
	DefaultEmailModel model = new DefaultEmailModel();
	model.setFrom("[email protected]", "Foobar");
	model.addTo("[email protected]", "Farboo");
	model.setSubject("Let's get things started");
	
	//create a simple HTML representation from plain text
	String text = "Make sure to check out http://www.github.com"; 
	String html = emailTemplateRendererService.textToHtml(text);
	model.setText(text);
	model.setHtml(html);
	
	emailService.sendMail(model);
	
	// ...or render a Thymeleaf template into HTML and automatically
	// provide a text only fallback version
	Map<String, Object> renderModel = new HashMap<>();
	renderModel.put("message", "Check out http://www.github.com");
	html = emailTemplateRendererService.render("someTemplate", emailModel, renderModel, Locale.ENGLISH);
	text = emailTemplateRendererService.htmlToText(html);
	model.setText(text);
	model.setHtml(html);
	
	emailService.sendMail(model);
}
org.sevensource.commons

SevenSource

Versions

Version
0.4.0
0.3.1
0.3.0
0.2.2
0.2.1
0.2.0
0.1.0