Skip to content

Commit

Permalink
Merge pull request #43 from JPro-one/jpro-mail-module
Browse files Browse the repository at this point in the history
Implementation of the `jpro-mail` module
  • Loading branch information
indritbeqiri committed Jul 11, 2024
2 parents 73cb463 + 13375f4 commit 6e79fd2
Show file tree
Hide file tree
Showing 25 changed files with 2,077 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
### 0.3.3-SNAPSHOT (TBD)

<<<<<<< jpro-mail-module
#### Features
* Implemented and added `jpro-mail` module to the platform. This module provides an API to send emails from a
JavaFX/JPro application.
=======
#### Improvements
* Updated **JPro** to version `2024.2.1`.
* Updated **SimpleFX** dependencies to version `3.2.34`.
Expand All @@ -10,6 +15,7 @@
`jpro-routing-dev` is included in the project.
* Fixed some dependency requirements in the `JPro Routing` modules.
* Fixed the stylesheet path in the `jpro-routing-popup` module for the SimplePopup control.
>>>>>>> main
----------------------

Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,28 @@ dependencies {
}
```

## [JPro Mail](https://github.com/JPro-one/jpro-platform/tree/main/jpro-mail)
This library provides a simple way to send emails in **JPro/JavaFX** applications. It allows you to send emails
using SMTP and SMTPS protocols. It also provides a simple way to compose and send emails with attachments.

#### Maven configuration
```xml
<dependencies>
<dependency>
<groupId>one.jpro.platform</groupId>
<artifactId>jpro-mail</artifactId>
<version>0.3.3-SNAPSHOT</version>
</dependency>
</dependencies>
```

#### Gradle configuration
```groovy
dependencies {
implementation("one.jpro.platform:jpro-mail:0.3.3-SNAPSHOT")
}
```

## [JPro Media](https://github.com/JPro-one/jpro-platform/tree/main/jpro-media)
This library is designed for audio and video playback and recording within JavaFX applications.
It seamlessly operates on both desktop and mobile devices, as well as in web browsers via **JPro**,
Expand Down Expand Up @@ -472,6 +494,7 @@ To run the examples, you can use the following commands:
./gradlew jpro-auth:example:run -Psample=oauth
./gradlew jpro-file:example:run -Psample=text-editor
./gradlew jpro-file:example:run -Psample=file-uploader
./gradlew jpro-mail:example:run -Psample=compose-mail
./gradlew jpro-media:example:run -Psample=media-player
./gradlew jpro-media:example:run -Psample=media-recorder
./gradlew jpro-media:example:run -Psample=media-recorder-and-player
Expand All @@ -489,6 +512,7 @@ To run the examples, you can use the following commands:
./gradlew jpro-auth:example:jproRun -Psample=oauth
./gradlew jpro-file:example:jproRun -Psample=text-editor
./gradlew jpro-file:example:jproRun -Psample=file-uploader
./gradlew jpro-mail:example:jproRun -Psample=compose-mail
./gradlew jpro-media:example:jproRun -Psample=media-player
./gradlew jpro-media:example:jproRun -Psample=media-recorder
./gradlew jpro-media:example:jproRun -Psample=media-recorder-and-player
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ configure(subprojects.findAll { it.name != 'example' }) {
}

configure([project("tree-showing"), project("jpro-auth:core"), project("jpro-auth:routing"), project("jpro-file"),
project("jpro-image-manager"), project("jpro-mdfx"), project("jpro-media"),
project("jpro-image-manager"), project("jpro-mail"), project("jpro-mdfx"), project("jpro-media"),
project("jpro-scenegraph"), project("jpro-session"),
project("jpro-html-scrollpane"), project("freeze-detector"), project("jpro-routing:core"),
project("jpro-routing:dev"), project("jpro-routing:popup"), project("jpro-webrtc"), project("jpro-youtube"),
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ FLEXMARK_VERSION = 0.64.8
JETBRAINS_ANNOTATIONS_VERSION = 24.1.0
AUTH0_JAVAJWT_VERSION = 4.4.0
AUTH0_JWKSRSA_VERSION = 0.22.1
JAKARTA_MAIL_API_VERSION = 2.1.3
ECLIPSE_ANGUS_MAIL_VERSION = 2.0.3
ECLIPSE_COLLECTIONS_VERSION = 11.1.0
CSSFX_VERSION = 11.5.1
IKONLI_VERSION = 12.3.1
ATLANTAFX_VERSION = 2.0.1
Expand Down
85 changes: 85 additions & 0 deletions jpro-mail/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# JPro Mail
A library that provides platform-independent and protocol-independent API for sending emails. The receiving of emails is
not yet implemented, but will be added in the future. These are currently the major components implemented:

- `MailConfig`: Represents the configuration for a mail client. It provides methods to get and set various properties
related to the mail configuration.

* Pre-included configurations
1. **GoogleMailConfig**: Provides a predefined configuration for connecting to the `Google Mail` (Gmail) SMTP
server. It sets specific properties required to use Gmail's SMTP server for sending emails.
2. **MailTrapConfig**: Provides a predefined configuration for connecting to the `MailTrap` SMTP server.
It sets specific properties required to use MailTrap's sandbox environment for sending emails.

* Usage Example

```java
MailConfig mailConfig = MailConfig.create();
mailConfig.setMailSmtpAuth(true);
mailConfig.setMailSmtpStartTLS(StartTLSOption.ENABLED);
mailConfig.setMailSmtpHost("smtp.gmail.com");
mailConfig.setMailSmtpPort(587);
```

- `MailClient`: Provides methods for creating and managing mail clients. It includes static methods to create instances
of MailClient and a method to create mail messages.

* Usage Example

```java
MailClient mailClient = MailClient.create(mailConfig, "SENDER_MAIL_USERNAME", "SENDER_MAIL_PASSWORD");
```

- `MailMessage`: Provides methods for creating and managing email messages. It includes methods to set and get various
email attributes such as sender, recipients, subject, and date, as well as methods to send and save the message.

* Usage Example

```java
MailMessage mailMessage = MailMessage.create(mailClient);
// Setting the sender's email address
mailMessage.addFrom("joe.doe@example.com");
// Setting the recipient email addresses
mailMessage.setTo(parseMailAddresses("alice@example.com, bob@example.com"));
// Setting the CC email addresses
mailMessage.setCc(parseMailAddresses("carol@example.com, dave@example.com"));
// Setting the BCC email addresses
mailMessage.setBcc(parseMailAddresses("eve@example.com, frank@example.com"));
// Setting the subject of the email
mailMessage.setSubject("Meeting Reminder");
// Setting the HTML content of the email
mailMessage.setHtml("<html><p>Dear team,</p><p>This is a reminder for the meeting scheduled at 3 PM tomorrow.</p><p>Best regards,<br>Joe</p></html>");
// Adding an attachment to the email
mailMessage.addAttachment(logoFile, "<logo>");
// Sending the email
mailMessage.send();
```

### Installation
- Gradle
```groovy
dependencies {
implementation("one.jpro.platform:jpro-mail:0.3.3-SNAPSHOT")
}
```
- Maven
```xml
<dependencies>
<dependency>
<groupId>one.jpro.platform</groupId>
<artifactId>jpro-mail</artifactId>
<version>0.3.3-SNAPSHOT</version>
</dependency>
</dependencies>
```

### Launch the examples
[**Compose Mail sample**](https://github.com/JPro-one/jpro-platform/blob/main/jpro-mail/example/src/main/java/one/jpro/platform/mail/example/compose/ComposeMailSample.java)
* As desktop application
```shell
./gradlew jpro-mail:example:run -Psample=compose-mail
```
* As JPro application
```shell
./gradlew jpro-mail:example:jproRun -Psample=compose-mail
```
8 changes: 8 additions & 0 deletions jpro-mail/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dependencies {
implementation "jakarta.mail:jakarta.mail-api:$JAKARTA_MAIL_API_VERSION"
runtimeOnly "org.eclipse.angus:angus-mail:$ECLIPSE_ANGUS_MAIL_VERSION"
implementation "org.jetbrains:annotations:$JETBRAINS_ANNOTATIONS_VERSION"
api "org.eclipse.collections:eclipse-collections-api:$ECLIPSE_COLLECTIONS_VERSION"
implementation "org.eclipse.collections:eclipse-collections:$ECLIPSE_COLLECTIONS_VERSION"
api "org.slf4j:slf4j-api:$SLF4J_API_VERSION"
}
29 changes: 29 additions & 0 deletions jpro-mail/example/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
id 'org.openjfx.javafxplugin'
id 'jpro-gradle-plugin'
}

dependencies {
implementation project(":jpro-mail")
implementation "io.github.mkpaz:atlantafx-base:$ATLANTAFX_VERSION"
implementation "org.kordamp.ikonli:ikonli-javafx:$IKONLI_VERSION"
implementation "org.kordamp.ikonli:ikonli-material2-pack:$IKONLI_VERSION"
implementation "org.slf4j:slf4j-api:$SLF4J_API_VERSION"
runtimeOnly "ch.qos.logback:logback-classic:$LOGBACK_VERSION"
}

javafx {
version = "$JAVAFX_VERSION"
modules = ['javafx.controls']
}

def examples = [
'compose-mail' : 'one.jpro.platform.mail.example.compose.ComposeMailSample'
]

mainClassName = project.hasProperty("sample") ? examples[project.getProperties().get("sample")] : examples["compose-mail"]

application {
mainClass = "$mainClassName"
mainModule = "one.jpro.platform.mail.example"
}
16 changes: 16 additions & 0 deletions jpro-mail/example/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Module descriptor for the example application.
*
* @author Besmir Beqiri
*/
module one.jpro.platform.mail.example {
requires javafx.controls;
requires jpro.webapi;
requires org.kordamp.ikonli.javafx;
requires org.kordamp.ikonli.material2;
requires atlantafx.base;
requires org.slf4j;
requires one.jpro.platform.mail;

exports one.jpro.platform.mail.example.compose;
}
Loading

0 comments on commit 6e79fd2

Please sign in to comment.