Giter Club home page Giter Club logo

go-mail's Introduction

Go Mail Server

A standalone server which its purpose is to only send email.

Required Environment Variables

Note: Before running the application, environment variables must be defined.
Instruction: Create a file .env inside your project directory, then add the variables with its corresponding values indicated in the table below.
Important Gmail Account Config: You will need to turn on Allow less secure apps on your gmail account.

Variables Definition Stage Values Prod Values
ENV Defines the environment the app will be running on. prod prod
PORT The port where the app will run 80 80
EMAIL Email address used by app for sending mails
EMAIL_PASSWORD Password for the email

Build application

go build -o mail .

Build and run application

Linux: go build -o mail . && ./mail
Windows: go build -o mail . && go run mail

Directory structure

mail
    - config
        - bash
        - docker
    - src
        - config
        - gmail
        - routes
    - main.go
config

Main Project configuration

Directory Definition
bash Script that allows docker to have access to environment variables in gitlab
docker Docker configuration for stage and prod
src

Contains the project source code.

Directory Definition
config Contains configuration for getting required values from environment variables
gmail Contains the logic for sending email using gmail api
routes Contains api route of the application for sending email
main.go

Entry point of the application.

API: Send email
  • https://yourdomain.com/api/send/mail
    body: {
        email: string
        message: string
        subject: string
    }
    method: "POST"
    
    Response:
    {
      Message: string
      Email: string
      Subject: string
    }
    

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.