Links

Send Mailer Endpoint

Send emails to users from your workspace.
URL
Requires Auth
HTTP Method
/api/v1/mailer
yes
POST

Headers

Argument
Example
Required
Description
X-User-Id
myuser-name
Required
The authenticated user ID.
X-Auth-Token
myauth-token
Required
Auth token.

Body Parameter

Argument
Example
Required
Description
from
Required
A valid email address to send mails from.
subject
Welcome to the Test Newsletter
Required
The subject of the email.
body
Today's newsletter is for our new users. Kindly click [unsubscribe] to unsubscribe from this newsletter.
Required
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
true
Required
A boolean value. If true, will only send one email to the same address as in the From parameter.

Example Call

curl --location 'http://localhost:3000/api/v1/mailer' \
--header 'x-auth-token: 1C9ajI4zUSlsefEchqaBesENo9Hw7Qa-Vh9x3VrS1iQ' \
--header 'x-user-id: rbAXPnMktTFbNpwtJ' \
--header 'Content-Type: application/json' \
--data-raw '{
"subject":"Welcome to the Test Newsletter",
"body":"Thank you for subscribing to the Test Newsletter. If this was not you feelfree to unsubscribe by hitting the following button [unsubscribe]"
}'

Example Result

Success

{
"success": true
}

Errors

The following errors can occur upon the endpoint.
  • Authorization: Requires an authentication token for the request to be made.
  • Invalid From Address: The from parameter was be a valid email address.
Authorization
Invalid From Address
{
"status": "error",
"message": "You must be logged in to do this."
}
{
"success": false,
"error": "Invalid from address [error-invalid-from-address]",
"errorType": "error-invalid-from-address",
"details": {
"function": "Mailer.sendMail"
}
}

Change Log

Version
Description
5.4.0
Added
Last modified 4mo ago
Rocket.Chat versions receive support for six months after release.