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/
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
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"
}
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).