Skip to content

Latest commit

 

History

History
84 lines (49 loc) · 2.02 KB

README.md

File metadata and controls

84 lines (49 loc) · 2.02 KB

Email Sending API

Contents

Install and Run

Install the project from Github and go to project directory via terminal

NOTE: Download and save project credentials before running the project.

Run following Commands:

npm install
node index.js

For testing the API is running:

Send a GET request to localhost:3000/

Initialization

Storing Credentials from Google

Create an app with redirection link as localhost:3000/api/authorize

Download and store the credentials in credentials.json file in home directory, and then run the app

Authorization

You need to give permission to the app for sending the mail from the respective accounts.

  • To give the permission send a get request to localhost:3000/api/initialize, you will recieve the following JSON response.
{
    "msg": "Authorize the API using the redirection link",
    "redirect": "link for authentication"
}
  • Copy the redirect link and paste it in browser

    • You will be asked to choose a Gmail account and give permission to send the mails.

    • On granting the permission the token will be automatically generated and stored.

On Successfull Initiaization you will receive the following response.

{
    "success": true,
    "msg": "Initialization Successful"
}

Sending Mail

NOTE: You must be authorized before sending the mail, otherwise you will be prompted to initialize first.

For sending mail send a POST request to localhost:3000/api/sendemail with following parameters:

to: Recepient Address

subject: Subject of Email

body: Body of Email

Clipping of how request for sending mail looks like(Postman).

Clipping of how request for sending mail looks like(Postman).