Send an Email

Send an email to the specified email address.

Request URL

POST {base_url}/{api_path}/system/sendemail?access_token={access_token}

Request parameters

Parameter Required Type Description
email_server Yes String The email server to send emails.
Valid values:
  • follow_system: Follow System
  • ys: Yeastar SMTP Server
  • custom: Custom Email Server
recipient No Array<String> Recipient email address.
cc No Array<String> Carbon Copy (CC) email address.
bcc No Array<String> Blind Carbon Copy (BCC) email address.
subject No String The subject of the email.
body No String The body content of the email.
attachments No Array<String> Email attachments.

Valid value: Absolute path to the files stored in the PBX's local storage. E.g. /ysdisk/syslog/pbxlog.log.

force_attach No Integer

Whether emails should be sent only when an attachment is included.

Valid value:

  • 0: Disable
  • 1: Enable

Response parameters

Parameter Type Description
errcode Integer Returned error code.
  • 0: Succeed.
  • Non-zero value: Failed.
Note: You can check the error code and error message in Error Code and Error Message.
errmsg String Returned message.
  • SUCCESS: Succeed.
  • FAILURE: Failed.

Examples

Request example
POST /openapi/v1.0/system/sendemail?access_token=n9lRd1ejSkrkc8AukPxYXTUt3wz5p7a2 HTTP/1.1
Host: 192.168.5.150:8088
Content-Type: application/json
{
  "email_server": "ys",
  "recipient": [
    "leo@yeastar.com",
    "dave@yeastar.com"
  ],
  "cc": [
    "test@yeastar.com"
  ],
  "bcc": [
    "demo@yeastar.com"
  ],
  "subject": "API Test",
  "body": "This is API Test",
  "attachments": [
    "/ysdisk/syslog/pbxlog.log"
  ],
  "force_attach": 0
}
Response example
HTTP/1.1 200 OK
{
    "errcode": 0,
    "errmsg": "SUCCESS"
}