Giter VIP home page Giter VIP logo

go-local-mail's Introduction

https://github.com/MariaLetta/free-gophers-pack

Go Local Mail

Handy little email interceptor, written in Go and using Mongo for storage (Currently only supporting Sendgrid V3 API)

Why go-local-mail?

Because having to setup an account and give out keys to send email while developing sucks!

When Developing most of the time all you need is:

  • A way to test that emails are being sent from our app
  • Tokens/urls they generate
  • Validate both text and html is as expected
  • Validate the email has been received
  • Store emails locally
  • Test the email component of our app

Features

Installation

clone the repo and docker-compose up to have local mail and the mongo document store running.

API

SendGrid V3 API

Support is build in for the Sendgrid v3 Api and uses the models they provide.

All unknown data will be stored as unused.

Send /v3/mail/send

Mocks the api endpoint used by Sendgrid, processes and stores data

Prints to stdout:

  • all recipients for the received email
  • email subject
  • URL for user interaction if one has been received
  • link to view text version
  • link to view html version
  • ID for the stored email

Example output from received request

2019/08/24 17:41:31 POST /v3/mail/send HTTP/1.1
Host: localhost:7893
Connection: close
Accept: application/json
Authorization: Bearer sometoken
Connection: close
Content-Length: 27121
Content-Type: application/json
User-Agent: sendgrid/5.2.3;nodejs

Recipients: [[email protected]] 
Subject: Welcome Aboard Bob
URL: http://localhost:8080/signup?verify=6c243fc6-4464-46d1-ac20-a6bf2a8d0edc
HTML: http://localhost:7893/v3/mail/html/id/5d60f133ef2c8961b458f589 
TXT: http://localhost:7893/v3/mail/text/id/5d60f133ef2c8961b458f589 
ID: 5d60f133ef2c8961b458f589

All /v3/mail/all

Returns all mail received and stored by the Sendgrid endpoint.

Example Stored email JSON representation

[
    {
        "_id": "5d60ecc4ef2c89508320ff21",
        "recipients": [
            "[email protected]"
        ],
        "subject": "Welcome Aboard Bob",
        "full": {
            ...
            ...
        },
        "createdAt": "2019-08-24T07:52:36.283Z"
    },
    {
        "_id": "5d60ee01ef2c895987da8f59",
        "recipients": [
            "[email protected]"
        ],
        "subject": "Welcome Aboard Bill",
        "full": {
            ...
            ...
        },
        "createdAt": "2019-08-24T07:57:53.490Z"
    }
]

GET /v3/mail/html/id/

Returns the html content of the email - useful for viewing html formatting of the email in the browser.

Example Retrieve html content of email

URL: http://localhost:7893/v3/mail/html/id/5d60f133ef2c8961b458f589

HTML email

GET /v3/mail/text/id/

Returns the text content of the email - useful for checking the email content in the terminal

$ curl http://localhost:7893/v3/mail/text/id/5d60f133ef2c8961b458f589
Hi, 

Welcome Aboard Bob.

YOUR ACCOUNT
http://localhost:8080/signup?verify=6c243fc6-4464-46d1-ac20-a6bf2a8d0edc

Sent by GopherLand
-

GET /v3/mail/text/link/id/

Returns the URL if it exists for an email given an ID - useful for pulling links out of emails

$ curl http://localhost:7893/v3/mail/text/link/id/5d60f133ef2c8961b458f589
http://localhost:8080/signup?verify=6c243fc6-4464-46d1-ac20-a6bf2a8d0edc

Local Data Storage

Stores the data locally for development.

Uses Mongo and admin-mongo (<--buy a coffee) to view and edit stored emails in the browser.

Navigate to http://localhost:1234/app/localmail to view entries

admin-mongo

go-local-mail's People

Contributors

jayco avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.