# README
Email Template Application
A web application built with Go and React for managing email templates and sending emails using custom SMTP configurations. This application allows you to create, save, and use email templates with dynamic content through JSON parsing.
Features
- Email template management (create, edit, save, delete)
- Generate email templates UI, backed by hermes
- SMTP configuration
- Dynamic content injection using JSON objects
- React-based web interface
- Template preview functionality
Project Structure
.
├── main.go
├── internal/
├── pkg/
├── frontend/ # React SPA
├── docker-compose.yml
└── README.md
Installation
Prerequisites
- Docker
- Docker Compose
Quick Start
# Clone the repository
git clone [your-repository-url]
# Navigate to project directory
cd [project-directory]
# Start the application using Docker Compose
docker compose up -d
The application will be available at http://localhost:5173
Configuration
Configure the application using environment variables in your docker-compose.yml
:
services:
backend:
environment:
- DB_URL=host=postgres user=postgres password=postgres dbname=api_email_client port=5432 TimeZone=America/Sao_Paulo
- DB_DIALECTOR=postgres
- [email protected]
- ADMIN_PASSWORD=admin00
- JWT_LIFESPAN=45
- JWT_SECRET=admin
- API_HOST=
- API_PORT=5555
Or you can use the .env.example
file as a template.
services:
backend:
env_file:
- .env
Cors
The application does not support CORS by default. It's desined to be used behind a reverse proxy, such as Nginx. If you need to enable CORS, you may open an issue or create a pull request.
Usage
Creating a Template
- Navigate to the "Templates" section
- Click "New Template"
- Fill in the template details:
- Template name
- Subject line
- HTML content
- Add placeholders using
{{.VariableName}}
syntax (Go template format)
You can also generate from UI a template using the "Generate" button
Configuring SMTP
- Go to "SMTP Settings"
- Add your SMTP configuration:
- Host
- Port
- Username
- Password
- SSL/TLS settings
Sending Emails
// Example JSON payload for sending an email
{
"template_slug": "welcome-template",
"smtp_slug": "main-smtp",
"to": "[email protected]",
"subject": "", // Optional
"data": { // The JSON object to be used as the template data
"UserName": "John Doe", // {{ .UserName }}
"ActivationLink": "https://yourdomain.com/activate/123" // {{ .ActivationLink }}
}
}
API Reference
Emails
POST /api/send
- Send email using templatePOST /api/send/:id/send
- Resend email
Development
The project consists of two main parts:
Backend (Go)
The Go backend is in the root directory. To develop locally:
# Install Go dependencies
go mod download
# Run the backend server
go run cmd/main.go
Frontend (React)
The React frontend is in the frontend
directory:
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start development server
npm run dev
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Support
For support, please open an issue in the GitHub repository