Skip to content

ham7a7/emailer_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Emailer API Documentation

This documentation provides an overview and usage guide for the Express.js API for sending email messages.

Endpoints

1. Send Email

Endpoint: POST /send/message

Description: This endpoint allows clients to send email messages.

Request Body

{
    "senderName": "The name of the sender of the email",
    "senderEmail": "The email of the sender",
    "message": "The message ",
    "receiverEmail": "receiver email coming from the clinet side"
}

Response

{
  "data":"Message sent"
}

Usage

To send an email, make a POST request to the /send/message endpoint with the required parameters in the request body.

Example Request using fetch function

fetch('your_server_url/send/message', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "senderName": "The name of the sender of the email",
    "senderEmail": "The email of the sender",
    "message": "The message ",
    "receiverEmail": "receiver email coming from the clinet side"
})
})
  .then(response => {
    if (!response.ok) {
      throw new Error('Network response was not ok');
    }
    return response.json();
  })
  .then(data => {
    return data;
  })
  .catch(error => {
    console.error('There was an error!', error);
    return 'Sorry, An error occurred!';
  });

Example Request using Axios

 axios
        .post('your_server_url/send/message', {
    "senderName": "The name of the sender of the email",
    "senderEmail": "The email of the sender",
    "message": "The message ",
    "receiverEmail": "receiver email coming from the clinet side"
})
        .then((res) => {
            return res.data
        })
        .catch((err) => {
            return 'Sorry, An error occured!';
        })

Dependencies

  • Express.js
  • nodemailer
  • body-parser
  • cors
  • dotenv

About

An API for sending email messages coming from your client side. Using Express.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published