spring-email

Java API to send emails in Spring

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.github.migangqui
ArtifactId

ArtifactId

spring-email-api-java
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

spring-email
Java API to send emails in Spring
Project URL

Project URL

https://github.com/migangqui/spring-email-api
Source Code Management

Source Code Management

https://github.com/migangqui/spring-email-api

Download spring-email-api-java

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.migangqui/spring-email-api-java/ -->
<dependency>
    <groupId>com.github.migangqui</groupId>
    <artifactId>spring-email-api-java</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.migangqui/spring-email-api-java/
implementation 'com.github.migangqui:spring-email-api-java:1.0.1'
// https://jarcasting.com/artifacts/com.github.migangqui/spring-email-api-java/
implementation ("com.github.migangqui:spring-email-api-java:1.0.1")
'com.github.migangqui:spring-email-api-java:jar:1.0.1'
<dependency org="com.github.migangqui" name="spring-email-api-java" rev="1.0.1">
  <artifact name="spring-email-api-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.migangqui', module='spring-email-api-java', version='1.0.1')
)
libraryDependencies += "com.github.migangqui" % "spring-email-api-java" % "1.0.1"
[com.github.migangqui/spring-email-api-java "1.0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-mail jar 2.2.5.RELEASE
com.fasterxml.jackson.core : jackson-annotations jar 2.9.8
commons-io : commons-io jar 2.5

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.16.18

Project Modules

There are no modules declared in this project.

Spring Email API (Java/Kotlin)

It is an API for Java and Kotlin to send emails with Spring. To add to the project, only do this things.

Add dependency to pom.xml

For Java:

<dependency>
	<groupId>com.github.migangqui</groupId>
	<artifactId>spring-email-api-java</artifactId>
	<version>${currentVersion}</version>
</dependency>

For Kotlin:

<dependency>
	<groupId>com.github.migangqui</groupId>
	<artifactId>spring-email-api-kotlin</artifactId>
	<version>${currentVersion}</version>
</dependency>

${currentVersion} is 1.0.1

Add the following properties in application.yml of the project

spring:
  mail:
    default-encoding: UTF-8
    host: # for example: smtp.gmail.com
    username: # Your email
    password: # Your email pass
    port: # SMPT port, for exaple: 25, 587
    properties:
      mail:
        transport.protocol: smtp
# Optional properties
#        smtp:
#          ssl:
#            trust: '*'
#          auth: true
#          starttls:
#            enable: true
#            required: true

Enable async

Add @EnableAsync annotation in your Spring Application class to enable async send method.

Component scan

It's not neccesary add the package to component scan with this new version.

How to use

You have to inject EmailService as dependency in your Spring component. The service provide these methods:

Java
public interface EmailService {
    SendEmailResult send(Email emailDTO);
        
    Future<SendEmailResult> sendAsync(Email emailDTO);
}
Kotlin
interface AmazonS3Service {
    fun send(email: Email): SendEmailResult

    fun sendAsync(email: Email): Future<SendEmailResult>
}

Versions

Version
1.0.1
1.0.0