spring-email

Java API to send emails in Spring

License

License

Categories

Categories

Kotlin Languages
GroupId

GroupId

com.github.migangqui
ArtifactId

ArtifactId

spring-email-api-kotlin
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-kotlin

How to add to project

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

Dependencies

compile (6)

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
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.71
org.jetbrains.kotlin : kotlin-reflect jar 1.3.71
io.github.microutils : kotlin-logging jar 1.6.10

provided (1)

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

test (1)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-test jar 1.3.71

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