Giter VIP home page Giter VIP logo

gobridge's Introduction

GoBridge

GoBridge is an SMTP to GMail API service. It will allow you to host an SMTP server that will accept emails and directly INSERT them into users' inboxes, bypassing any filtering. This is achieved by using the GMail API; and specifically the users.messages.insert endpoint.

You will need to create and authorize a service account, save the service_secret.json file to the working directory, and delegate domain-wide authority for the service account. This will give permission to impersonate any user and insert the email into their inbox. For a step by step list of instructions please see GMailSetup.md

Package Installation

Run pip3 install -r requirements.txt to install the appropriate packages.

Configuration

Appropriate settings can be defined in the config.json file. The default values are:

[GOBRIDGE]
ClientSecretFile = service_secret.json
SMTPPort = 2500
SMTPInterface = localhost
Labels = INBOX,UNREAD,IMPORTANT,STARRED

The Labels section refer to GMail labels - the default values ensure the email will be as visible as possible to the user.

Make sure the service_secret.json file has been generated and downloaded.

Running

Simply run the Python file, for example:

$ python3 GoBridge.py

   _____       ____       _     _            
  / ____|     |  _ \     (_)   | |           
 | |  __  ___ | |_) |_ __ _  __| | __ _  ___ 
 | | |_ |/ _ \|  _ <| '__| |/ _` |/ _` |/ _ \
 | |__| | (_) | |_) | |  | | (_| | (_| |  __/
  \_____|\___/|____/|_|  |_|\__,_|\__, |\___|
                                   __/ |     
                                  |___/

                     SMTP to GMail API Server
                     V0.1

[+] Running GoBridge SMTP server on port  2500
[+] Successfully inserted message for [email protected] with Id: 186b32c792dcd88e
[+] Successfully inserted message for [email protected] with Id: 186b32c82342242f
[+] Successfully inserted message for [email protected] with Id: 186b32c8abc5f0b0
[!] An error occurred inserting mail for [email protected]: invalid_grant: Invalid email or User ID
[!] An error occurred inserting mail for [email protected]: invalid_grant: Invalid email or User ID

As can be seen in the above output email addresses not in the scope of the service account will be rejected.

Docker build

In order to build docker image, need to run docker build -t GoBridge .

Docker running

To run GoBridge into docker image, need to set up few variables specify into .env.example

  • First need to copy .env.exampke into .env file cp .env.example .env
  • Run cat service_secret.json|base64 and copy value and set value of GOOGLE_SECRET_BASE64_ENCODED with output value

Now you can run docker run -p 2500:2500 -t --env-file=.env GoBridge

References:

https://developers.google.com/gmail/api/reference/rest/v1/users.messages/insert https://console.cloud.google.com/iam-admin/serviceaccounts https://developers.google.com/identity/protocols/oauth2/service-account#creatinganaccount https://developers.google.com/cloud-search/docs/guides/delegation#python https://stackoverflow.com/questions/42438902/gmail-api-user-impersonation-python

gobridge's People

Contributors

glennzw avatar luke-from-it avatar thomasisaacsibille avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gobridge's Issues

Setup from env variable

In order to deploy Gobridge on docker, we don't want to add secret.json in docker build phase.
Also need to lister port 0.0.0.0 for docker port exposed

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.