Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/migangqui/spring-email-api
Spring Email API for Java and Kotlin
https://github.com/migangqui/spring-email-api
api java kotlin maven spring
Last synced: 8 days ago
JSON representation
Spring Email API for Java and Kotlin
- Host: GitHub
- URL: https://github.com/migangqui/spring-email-api
- Owner: migangqui
- License: mit
- Created: 2019-03-21T20:50:16.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-03T17:03:21.000Z (3 months ago)
- Last Synced: 2024-11-16T01:10:21.834Z (about 1 month ago)
- Topics: api, java, kotlin, maven, spring
- Language: Java
- Homepage: https://migangqui.github.io/spring-email-api/
- Size: 51.8 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Spring Email API (Java/Kotlin)
==============================![GitHub last commit](https://img.shields.io/github/last-commit/migangqui/spring-email-api?style=for-the-badge)
![Maven Central](https://img.shields.io/maven-central/v/com.github.migangqui/spring-email-api-java?style=for-the-badge)It is an API for Java and Kotlin to send emails with Spring. To add to your project...
### Add dependency to Maven or Gradle:
For Java:
```xml
com.github.migangqui
spring-email-api-java
${currentVersion}```
```groovy
implementation 'com.github.migangqui:spring-email-api-java:${currentVersion}'
```For Kotlin:
```xml
com.github.migangqui
spring-email-api-kotlin
${currentVersion}```
```groovy
implementation 'com.github.migangqui:spring-email-api-kotlin:${currentVersion}'
``````${currentVersion}``` is ```1.2.0```
### Add the following properties in application.yml of the project
```yaml
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 necessary add the package to component scan with this new version.
## How to use
You have to inject ```EmailSender``` as dependency in your Spring component. The service provide these methods:
##### Java
```java
public interface EmailSender {
SendEmailResult send(Email email);
Future sendAsync(Email email);
}
```
##### Kotlin
```kotlin
interface EmailSender {
fun send(email: Email): SendEmailResultfun sendAsync(email: Email): Future
}
```