An open API service indexing awesome lists of open source software.

https://github.com/renanbreier/java-email-sender

A Spring Boot project for sending emails with Amazon SES, inspired by a technical challenge from Uber. Built with Clean Code principles and secure integration with AWS.
https://github.com/renanbreier/java-email-sender

api-rest aws clean-architecture java maven ses spring

Last synced: about 2 months ago
JSON representation

A Spring Boot project for sending emails with Amazon SES, inspired by a technical challenge from Uber. Built with Clean Code principles and secure integration with AWS.

Awesome Lists containing this project

README

          

# 📧 Java Email Sender with Amazon SES

This project is a **Spring Boot application** that integrates with **Amazon Simple Email Service (SES)** to send emails reliably and securely.
It demonstrates how to configure AWS SDK in a Spring application and send transactional or notification emails via Amazon SES.

---

## 🚀 Features
- Send emails using **Amazon SES**
- Integration with **Spring Boot** and **AWS SDK**
- Configurable via **environment variables** (no credentials in code)
- Follows **Clean Code principles** for better readability and maintainability
- Secure development with **GitHub Push Protection**

---

## 🛠️ Technologies Used
- **Java 17+**
- **Spring Boot**
- **AWS SDK for Java (SES)**
- **Maven**

---

## ⚙️ Configuration

Before running the project, make sure you have:

1. **AWS Account** with Amazon SES enabled
2. **Verified sender email address** in SES
3. **Access Key & Secret Key** from AWS IAM (with SES permissions)

### Set your AWS credentials
The application uses environment variables (or `~/.aws/credentials`) for security.
Export them in your shell:

```bash
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_REGION=us-east-1
```

Or configure in `~/.aws/credentials`:

```ini
[default]
aws_access_key_id=your_access_key
aws_secret_access_key=your_secret_key
region=us-east-1
```

---

## ▶️ Running the Application

Clone the repository:

```bash
git clone https://github.com/renanbreier/Java-Email-Sender.git
cd Java-Email-Sender
```

Build and run with Maven:

```bash
mvn spring-boot:run
```

---

## ✉️ Sending an Email

Once the application is running, you can trigger the email sending service by calling the method in your code or exposing an endpoint (/api/email).

Example (inside your service):

```java
sesClient.sendEmail(new SendEmailRequest()
.withDestination(new Destination().withToAddresses("recipient@example.com"))
.withMessage(new Message()
.withSubject(new Content("Test Email from SES"))
.withBody(new Body().withText(new Content("Hello, this is a test email."))))
.withSource("your_verified_email@example.com"));
```

---

## 📌 Notes
- Make sure the **sender email address is verified** in Amazon SES.
- In **sandbox mode**, SES only allows sending to verified addresses. To lift restrictions, request production access in AWS.
- This project follows **Clean Code practices** such as meaningful names, small methods, separation of concerns, and proper package structure.

---

## 📝 Author
Renan Breier.