Send Email API

This API allows you to send emails using different email services like Gmail, Outlook, and Yandex. You can dynamically specify the email service, or if none is provided, it defaults to Gmail.

API Endpoint

URL: https://mail-send-api2.onrender.com/send-email

Method: POST

Request Body Parameters

Parameter Type Description Required
email string Your email address Yes
password string Your email account's app password Yes
to string Recipient's email address Yes
subject string Subject of the email Yes
text string Body of the email Yes
service string (Optional) Email service provider (gmail, outlook, yandex). Defaults to gmail if not provided. No

Example Usage

Sending an Email with Gmail (Default)

curl -X POST https://mail-send-api2.onrender.com/send-email \
-H "Content-Type: application/json" \
-d '{
  "email": "[email protected]",
  "password": "your-gmail-app-password",
  "to": "[email protected]",
  "subject": "Subject",
  "text": "message text"
}'

Sending an Email with Outlook

curl -X POST https://mail-send-api2.onrender.com/send-email \
-H "Content-Type: application/json" \
-d '{
  "email": "[email protected]",
  "password": "your-outlook-app-password",
  "to": "[email protected]",
  "subject": "Subject",
  "text": "message text",
  "service": "outlook"
}'

Sending an Email with Yandex

curl -X POST https://mail-send-api2.onrender.com/send-email \
-H "Content-Type: application/json" \
-d '{
  "email": "[email protected]",
  "password": "your-yandex-app-password",
  "to": "[email protected]",
  "subject": "Subject",
  "text": "message text",
  "service": "yandex"
}'
Note:

Make sure you have enabled "Less secure app access" or generated an "App Password" for your email account to use this API.

The service parameter is optional. If not provided, the API will default to using Gmail.

Error Handling

If any required fields are missing, the API will return a 400 Bad Request status with an appropriate error message.

If there is an issue with sending the email, the API will return a 500 Internal Server Error status with the error details.

GitHub Osman Beyhan