Skip to content

An intelligent, lightweight Spring Boot API that automatically replies to incoming emails based on message keywords using FreeMarker HTML templates.

License

Notifications You must be signed in to change notification settings

Hariharan1893/Auto-Email-Responder-Api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated Email Responder API

An intelligent, lightweight Spring Boot API that automatically replies to incoming emails based on message keywords using FreeMarker HTML templates.

Developed with ❤️ for DtPix Studios


Features

  • Automatically detects keywords like pricing, services, and support
  • Sends pre-defined HTML responses via Gmail SMTP
  • Uses FreeMarker for dynamic templating
  • Minimalistic single-endpoint API
  • Fully customizable email templates

Tech Stack

  • Java 21+
  • Spring Boot 3.x
  • JavaMailSender
  • FreeMarker Templates
  • Gmail SMTP

API Endpoint

1. Send Auto-Response Email

POST /api/email/send-auto-response

Receives a JSON payload with senderEmail, subject, and message. Responds automatically based on detected keywords in the message.

Request Body

{
  "senderEmail": "client@example.com",
  "subject": "Need pricing info",
  "message": "Hi team, could you please share pricing details?"
}

Response (Success)

Auto-response sent successfully!

Response (Error)

Error: senderEmail and message are required fields.

Template Mapping

The keyword in the message body determines which template to use:

Keyword Template File
pricing pricing.ftl
services services.ftl
support support.ftl
(default) default_response_template.ftl

Templates are stored in:
src/main/resources/templates/


Getting Started

1. Clone the Repository

bash

git clone https://github.com/Hariharan1893/Auto-Email-Responder-Api.git

cd Auto-Email-Responder-Api

2. Set up your MySQL database

sql

CREATE DATABASE email_responder_db;

3. Configure SMTP and DB in application.yml or application.properties

Make sure to provide your Gmail and DB credentials.

4. Build and Run the Project

bash

./mvnw spring-boot:run

Or if you’re using Maven directly:

bash

mvn clean install
mvn spring-boot:run

SMTP Configuration

Ensure your application.yml or application.properties contains:

server:
  port: 8080

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/your-db
    username: root
    password: your-db-password
    driver-class-name: com.mysql.cj.jdbc.Driver

  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true
    database-platform: org.hibernate.dialect.MySQL8Dialect

  mail:
    host: smtp.gmail.com
    port: 587
    username: your-company-mail
    password: your-app-password
    properties:
      mail:
        smtp:
          auth: true
          starttls:
            enable: true
            required: true
          connectiontimeout: 5000
          timeout: 5000
          writetimeout: 5000

  freemarker:
    template-loader-path: classpath:/templates/
    suffix: .ftl
    charset: UTF-8

logging:
  level:
    org:
      springframework:
        web: DEBUG
        mail: DEBUG

You must use an App Password if your Gmail has 2FA enabled.


Example Test (Postman or cURL)

curl -X POST http://localhost:8080/api/email/send-auto-response \
  -H "Content-Type: application/json" \
  -d '{
        "senderEmail": "client@example.com",
        "subject": "Looking for services",
        "message": "Can you provide more info on your services?"
      }'

👨Developed by

📧 hariramesh1893@gmail.com
🌐 Hariharan


About

An intelligent, lightweight Spring Boot API that automatically replies to incoming emails based on message keywords using FreeMarker HTML templates.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published