> ## Documentation Index
> Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Mailer Endpoint

> Send emails to users from your workspace. Make sure that you have configured the <a href='https://docs.rocket.chat/docs/configure-email' target='_blank'>email settings</a> in the workspace.

| Version      | Description |
| ---------------- | ------------|
|5.4.0      | Added      |

## OpenAPI

````json POST /api/v1/mailer
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Miscellaneous"
  },
  "servers": [
    {
      "url": "https://apiexplorer.support.rocket.chat"
    }
  ],
  "paths": {
    "/api/v1/mailer": {
      "post": {
        "tags": [
          "Mailer"
        ],
        "summary": "Send Mailer Endpoint",
        "description": "Send emails to users from your workspace. Make sure that you have configured the <a href='https://docs.rocket.chat/docs/configure-email' target='_blank'>email settings</a> in the workspace.\n\n| Version      | Description |\n| ---------------- | ------------|\n|5.4.0      | Added      |",
        "operationId": "post-api-v1-mailer",
        "parameters": [
          {
            "$ref": "#/components/parameters/Auth-Token"
          },
          {
            "$ref": "#/components/parameters/UserId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string",
                    "description": "A valid email address to send mails from."
                  },
                  "subject": {
                    "type": "string",
                    "description": "The subject of the email."
                  },
                  "body": {
                    "type": "string",
                    "description": "The body of the email. You must use `[unsubscribe]` for the unsubscription link. You may use `[name]`, `[fname]`, `[lname]` for the user's full name, first name or last name, respectively. You may use `[email]` for the user's email."
                  },
                  "dryrun": {
                    "type": "string",
                    "description": "A boolean value. If true, will only send one email to the same address as in the `From` parameter."
                  }
                },
                "required": [
                  "from",
                  "subject"
                ]
              },
              "examples": {
                "Example": {
                  "value": {
                    "from": "test.test@test.com",
                    "subject": "Welcome to the Test Newsletter",
                    "body": "Thank you for subscribing to the Test Newsletter. If this was not you feel free to unsubscribe by hitting the following button [unsubscribe]",
                    "dryrun": "true"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/trueSuccess"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "string"
                    },
                    "errorType": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "properties": {
                        "function": {
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "Invalid From Address": {
                    "value": {
                      "success": "false",
                      "error": "Invalid from address [error-invalid-from-address]",
                      "errorType": "error-invalid-from-address",
                      "details": {
                        "function": "Mailer.sendMail"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/authorizationError"
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "Auth-Token": {
        "name": "X-Auth-Token",
        "in": "header",
        "description": "The `authToken` of the authenticated user.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "RScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f"
      },
      "UserId": {
        "name": "X-User-Id",
        "in": "header",
        "description": "The `userId` of the authenticated user.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "rbAXPnMktTFbNpwtJ"
      }
    },
    "responses": {
      "trueSuccess": {
        "description": "OK",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "success": {
                  "type": "boolean"
                }
              }
            },
            "examples": {
              "Success": {
                "value": {
                  "success": "true"
                }
              }
            }
          }
        }
      },
      "authorizationError": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            },
            "examples": {
              "Authorization Error": {
                "value": {
                  "status": "error",
                  "message": "You must be logged in to do this."
                }
              }
            }
          }
        }
      }
    }
  }
}
````

