- Base URL:
https://localhost:3000
This endpoint is used to send an email with the specified parameters.
- Method: POST
- Headers:
Content-Type
: application/json
- Body:
to
(string, required): Email address of the recipient.subject
(string, required): Subject of the email.text
(string, required): Body of the email.name
(string): Name of the sender (optional).email
(string): Email address of the sender (optional).phone
(string): Phone number of the sender (optional).message
(string): Additional message from the sender (optional).
- Success Response:
- Status Code: 200 OK
- Body:
{ "success": "Email sent successfully", "info": "<details about the sent email>" }
- Error Response:
- Status Code: 400 Bad Request or 500 Internal Server Error
- Body:
{ "error": "Failed to send email", "details": "<error message>" }
Create a .env
file in the root of your project and define the following variables:
GMAIL_TOKEN
: Token for Gmail authentication.GMAIL_USER
: Gmail user email address.URL_ORIGIN
: Origin URL for your product.PORT
: Port on which the server will run.
GMAIL_TOKEN=your_gmail_token
GMAIL_USER=[email protected]
URL_ORIGIN=http://your-web-consumer-url.com
PORT=3000
To start the server, run the following command in your terminal:
node server.js
curl -X POST http://localhost:3000/send-email \
-H "Content-Type: application/json" \
-d '{
"to": "[email protected]",
"subject": "Test Subject",
"text": "This is a test email",
"name": "",
"email": "",
"phone": "",
"message": ""
}'