> For the complete documentation index, see [llms.txt](https://vongnyuksoon2000.gitbook.io/simplemail/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vongnyuksoon2000.gitbook.io/simplemail/api-endpoints/send-email.md).

# Send email

## Send email

<mark style="color:green;">`POST`</mark> `https://simplemail-nodejs.herokuapp.com/send-email`

Sending email and send request to another server.

#### Request Body

| Name                                         | Type   | Description                                                                                                                                                                                                                                                                                                                                    |
| -------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| email<mark style="color:red;">\*</mark>      | String | The email of the receiver.                                                                                                                                                                                                                                                                                                                     |
| from<mark style="color:red;">\*</mark>       | String | The email of the sender.  Same as the one that provided in `smtp_user`.                                                                                                                                                                                                                                                                        |
| subject<mark style="color:red;">\*</mark>    | String | The subject of the mail.                                                                                                                                                                                                                                                                                                                       |
| text<mark style="color:red;">\*</mark>       | String | The text of the email. If `html` is provided, this field will be overwritten.                                                                                                                                                                                                                                                                  |
| html                                         | String | The raw html.                                                                                                                                                                                                                                                                                                                                  |
| smtp\_pass<mark style="color:red;">\*</mark> | String | The app password of your Gmail account.                                                                                                                                                                                                                                                                                                        |
| smtp\_user<mark style="color:red;">\*</mark> | String | The email of your Gmail account.                                                                                                                                                                                                                                                                                                               |
| callback\_url                                | String | <p>The url you want to call after sending email to receiver. </p><p></p><p>\*exclude localhost</p>                                                                                                                                                                                                                                             |
| callback\_data                               | String | The data you want to send along with the callback\_url after sending email to receiver.                                                                                                                                                                                                                                                        |
| method                                       | String | <p> Methods of your <code>callback\_url</code></p><p>eg: POST, GET, PUT, PATCH, DELETE</p>                                                                                                                                                                                                                                                     |
| send\_at                                     | String | <p>The datetime you want the email get sent. Make sure the provided value is less or equal than 7 days. </p><p></p><p>eg: "<strong>2021-11-26 23:59</strong>"</p><p></p><p><mark style="color:red;">\*</mark>This function is not very stable since the server is hosting at Heroku with hobby plan, it may not work due to the idle stuff</p> |
| timezone                                     | String | <p>Timezone for <code>send\_at</code>.</p><p></p><p></p><p>Default value: "<strong>Asia/Kuala\_Lumpur"</strong></p>                                                                                                                                                                                                                            |

{% tabs %}
{% tab title="201: Created The returned response if the email is sent to the receiver. If `callback_url` cannot be called for some reason, then will send a email to notify email which is defined at `smtp_user`" %}

```javascript
// Not scheduled email
{
    "msg": "Success"
}

// Is scheduled email
{
    "msg": "Success",
    // same with rescheduleID if `callback_url` is not provided
    "cancelID": "2js4h23a-3767-4130-bfb9-56425f406da9", 
    "rescheduleID": "w12hj21-3767-4130-bfb9-56425f406da9"
}
```

{% endtab %}

{% tab title="500: Internal Server Error When required data is missing." %}

```javascript
{
    "msg": "Invalid data passed"
}
```

{% endtab %}

{% tab title="500: Internal Server Error When gap in days of `send_at` and current is more than 7 days. (Max. gap\*: 7 days)" %}

```javascript
{    
    "msg": "[send_at] is more than 7 days (has gap in days as: <<GAP_IN_DAYS>>), please make sure you provide date that has less or equal than 7 days."
}
```

{% endtab %}

{% tab title="500: Internal Server Error When `send_at` is invalid format" %}

```javascript
{
    "msg": "[send_at] is invalid"
}
```

{% endtab %}

{% tab title="500: Internal Server Error When `send_at` is outdated" %}

```javascript
{
    "msg": "[send_at] is outdated."
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vongnyuksoon2000.gitbook.io/simplemail/api-endpoints/send-email.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
