Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SMTP email service integration using Spring Boot Mail Starter #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

faizakram
Copy link
Owner

This pull request introduces SMTP email service integration to the application using the spring-boot-starter-mail dependency, along with a new test endpoint to verify email functionality.

Key Features

  1. SMTP Email Integration:

    • Configures the application to use an SMTP server for sending emails.
    • Supports sending simple text emails, HTML emails, and emails with attachments.
  2. Test Endpoint for Sending Emails:

    • Adds a POST endpoint to send emails using SMTP with dynamic parameters for the recipient (to), subject (subject), and body (body).
    • Facilitates quick testing of email functionality to ensure proper SMTP configuration.
  3. Flexible Configuration:

    • Uses Spring Boot’s application.properties or application.yml for configuring SMTP settings (e.g., server host, port, username, password, etc.).
    • Allows dynamic configuration to adapt to different environments (development, testing, production).
  4. Ready for Future Enhancements:

    • Provides a foundation for implementing advanced email features, such as templated emails, batch email processing, and event-driven notifications.

How to Configure SMTP Email Service

To configure the SMTP email service, add the following properties to your application.properties or application.yml:

spring.mail.host=smtp.example.com
spring.mail.port=587
spring.mail.username=your-username
spring.mail.password=your-password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true

### How to Test

1. **Test Endpoint for Sending Emails:**
   - Adds a `POST` endpoint to send emails using SMTP with dynamic parameters for the recipient (`to`), subject (`subject`), and body (`body`).
   - Useful for developers and testers to validate the email service integration quickly.

2. **Dynamic Email Content:**
   - Supports dynamic email content by allowing `to`, `subject`, and `body` parameters to be passed in the request URL.
   - Enables easy testing with different email content variations.

### How to Test

To test the SMTP email service, use the following `POST` request:

```bash
curl --location --request POST 'http://localhost:8080/email?to={{$placeholder}}&subject={{$random.alphanumeric(8)}}&body={{$random.alphanumeric(8)}}'

faizorg and others added 3 commits March 23, 2024 13:01
@faizakram faizakram added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants