Email dispatcher API

Last update: 7th September, 2022

This application provides you with an api to send emails. It is implemented using the node mailer package.

Before usage

This application uses the gmail service so ensure that you have enabled less secure app permission for your gmail account

Versions

Example usage

        let user = userInput.value;
        let pass = passInput.value;
        let from = fromInput.value;
        let to = toInput.value;
        let subject = subjectInput.value;
        let html = htmlInput.value;

        let data = { 
            user: user, 
            pass: pass, 
            from: from,
            to: to,
            subject: subject,
            html: html
        };
        let url = "http://localhost:3000/api/v1";

        sendPostRequest(url, data)
            .then(json => {
                console.log(json); //success { status: 'success'} | failed { status: 'failed', message: 'error message'}
            }).catch(err => {
                console.error(err);
            });

        async function sendPostRequest(url, data) {
            let response = await fetch(url, {
                method: "POST",
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(data)
            });

            let json = await response.json();

            return json;
        }
    

Parameters

user
This is the gmail address through which the email will be sent. Make sure it has Less secure app permission enabled
pass
The password of the gmail account used to send the email
from
A String identifying who sent the email
to
A comma seperated list of email address recipients
subject
The subject of the email to be displayed in the list view
html
The email message to be formated in html
host (v2)
The email server host through which the email will be sent. It is smtp.gmail.com for gmail. for namecheap, it is something like server313.web-hosting.com
attachments (v3)
Send attachments which should be base64 encoded in the form of a JSON string in the body of the request. Include the filename, content, encoding as an object in an array