Skip to content

Send Basic Emails API

Backendless provides API for basic email delivery. The API lets you specify:

  • plain text and/or HTML-based content for your email messages;
  • a list of email address for the recipient;
  • a list of attachments;

Important

Before the API can be used, the Backendless backend must be configured with your own SMTP server information. This is an important requirement as the API will not work when the Manage > App Settings > Email Settings section in Backendless Console contains default values. For instructions on how to configure your own SMTP server in Backendless, see the Email Settingssection.

Sending Email API

Delivers an email message to the recipient(s) specified in the API call.

Method:

POST


URL

https://api.backendless.com/<app-id>/<REST-api-key>/messaging/email

where:

Argument                Description
<application-id> the ID of your application generated upon its creation. You can get the value in the Manage > App Settings section of the Backendless Console.
<REST-api-key> REST API key of your application. You can get the value from the Manage > App Settings section of the Backendless Console.

Request headers

Content-Type: application/json  
user-token: optional value obtained as a result of the login operation.

where:

Argument                Description
Content-Type Must be set to application/json. This header is mandatory.
user-token Optional header. Contains a value returned by Backendless in a preceding user Login API call. If user-token is set in the request, the currently logged in user will be assigned to the ownerId property of the user object which is being saved.  Additionally, the operation will be executed with the security policy associated currently logged in user. This means all permissions associated with the user and the roles assigned to the user will be enforced by Backendless.

Request body

{  
  "subject" : value,  
  "bodyparts" : {  
     "textmessage" : value,  
     "htmlmessage" : value  
   },  
  "to" : [ array of values ],  
  "attachment" : [ array of file paths from the Backendless File Service ]  
}

where:

Argument                Description
subject Email message subject.
bodyparts.textmessage Plain text body of the email message.
bodyparts.htmlmessage HTML version of the body of the email message.
to An array of email addresses to deliver the email message to.
attachment An array of file paths for the file entries from the Backendless File Service. Referenced files will be attached to the email message. The path is calculated from the root of the file system without the leading slash. For example if file agreement.txt is located at /documents/legal/, then the path in the REST request must be documents/legal/agreement.txt.

Example

curl \  
-H Content-Type:application/json \   
-X POST \  
-d '{"subject":"Hello World!", "bodyparts":{"textmessage":"This is an email message sent by Backendless"}, "to":["james.bond@mi6.co.uk"]}' https://api.backendless.com/XXXXX-XXXXX-XXXXX/ZZZZZ-ZZZZZ-ZZZZZ/messaging/email

Sending an email with an attachment:

curl \  
-H Content-Type:application/json \  
-X POST \  
-d '{ "subject": "Sample email with attachment", "bodyparts": { "textmessage":"Here's a sample attachment..." }, "attachment": [ "web/index.html" ], "to": [ "james.bond@mi6.co.uk" ] }'  https://api.backendless.com/XXXXX-XXXXX-XXXXX/ZZZZZ-ZZZZZ-ZZZZZ/messaging/email