Skip to content

This API uses gmail API to send mails without any 3rd party packages or libraries.

Notifications You must be signed in to change notification settings

ayushag99/email_sending_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

This API uses gmail API to send mails without any 3rd party packages or libraries.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published