Last update: 7th September, 2022
This application provides you with an api to send emails. It is implemented using the node mailer package.
This application uses the gmail service so ensure that you have enabled less secure app permission for your gmail account
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;
}