Code Monkey home page Code Monkey logo

hermes's Introduction

Hermes

Mailer micro-service for vandeas

Table of content

Environment Variables

To run this project, you will need to add the following environment variables

  • CONTACT_FORM_CONFIGS_FOLDER: An existing folder in your file system where the contact form configs will be stored.
  • MAIL_CONFIGS_FOLDER: An existing folder in your file system where the email configs will be stored.
  • TEMPLATES_FOLDER: An existing folder in your file system where the email templates will be stored.
  • GOOGLE_RECAPTCHA_SECRET: A Google ReCaptcha secret (required only when using forms).

Documentation

Supported Mail Providers

  • Sendgrid Removed due to lack of support for batch emails requests
  • Resend
  • Custom SMTP server, that can be configured in the email & contact form configs

Contact Form

Example of CONTACT_FORM_CONFIGS_FOLDER configuration files

Resend-based config

{
    "id": "UUID",
    "dailyLimit": 10,
    "destination": "[email protected]",
    "sender": "[email protected]",
    "threshold": 0.5, // Recapthca score thresold
    "lang": "fr", // ISO 639-1
    "subjectTemplate": "New mail from {{form.firstName}}",
    "provider": "RESEND",
    "apiKey": "<YOUR_RESEND_API_KEY>"
}

SMTP-based config

{
    "id": "UUID",
    "dailyLimit": 10,
    "destination": "[email protected]",
    "sender": "[email protected]",
    "threshold": 0.5, // Recapthca score thresold
    "lang": "fr", // ISO 639-1
    "subjectTemplate": "New mail from {{form.firstName}}",
    "provider": "SMTP",
    "username": "<SMTP_USERNAME>",
    "password": "<SMTP_PASSWORD>",
    "smtpHost": "<SMTP_SERVER_IP>",
    "smtpPort": "<SMTP_SERVER_PORT>"
}

Filename does not have to respect any convention.

Mail config

Example of MAIL_CONFIGS_FOLDER configuration files

Resend-based config

{
    "id": "UUID",
    "sender": "[email protected]",
    "subjectTemplate": "New mail from {{form.firstName}}",
    "provider": "RESEND",
    "apiKey": "<YOUR_RESEND_API_KEY>"
}

SMTP-based config

{
    "id": "UUID",
    "sender": "[email protected]",
    "subjectTemplate": "New mail from {{form.firstName}}",
    "provider": "SMTP",
    "username": "<SMTP_USERNAME>",
    "password": "<SMTP_PASSWORD>",
    "smtpHost": "<SMTP_SERVER_IP>",
    "smtpPort": "<SMTP_SERVER_PORT>"
}

Mail template

Filename should be {{UUID}}.hbs (same UUID as the id field in the Contact Form or Mail config)

API Reference

Send contact form using contact form configuration

POST /v1/mail/contact

Body
Attribute Type Description
id string Required. Your contact form config id
fullName string Required Full name of the person that sent the form
email string Required Email of the person that sent the form
content string Required Content of the message
recaptchaToken string Required Result token/secret of recaptcha

Send mail using mail configuration

POST /v1/mail

Body
Attribute Type Description
id string Required. Your mail config id
email string Required Email of the person to sent the mail to
attributes Map<string, string> / JSON Object Required Attributes to hydrate the mail template

Send batch of mails using mail configurations

POST /v1/mail/batch

Body
Attribute Type Description
mails Array<Mail> Required. Array of mails to send
[
    {
        "id": "UUID", // Mail config id
        "email": "[email protected]",
        "attributes": {
            "firstName": "John",
            "lastName": "Doe"
        }
    }
]

Roadmap

  • Better templating system (currently stored in /resources/templates)
  • Endpoint to send email
  • Watch and reload configuration files and templates

hermes's People

Contributors

lotuxpunk avatar testadirapa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.