Sending an email is a very common operation for many applications. For most of them, it is the server-side that is responsible for delivering an email message. Backendless makes it trivially easy to deliver a branded email (meaning it will look like it was sent by your app) in the plain text or HTML formats (or both).
Consider the following code, which sends an HTML-formatted email message:
The code above sends an HTML-formatted email to one recipient. You can also create an array of email addresses to use instead. That way, an email will be delivered to a group of recipients.
If you run the code above without making any configuration changes to your Backendless backend, you will receive the following error:
This error occurs when you try using the functionality for sending an email and do not change the Email Settings. By default, every Backendless backend is configured to use our special email account. That account does not let you use the API demonstrated above – you need to change it to your SMTP account. To do that:
Below is a screenshot of the settings after making the changes described above:
Now when we run the same code, we get the following output:
When the email arrives, it looks exactly as expected – an HTML-formatted email:
There are plenty of methods to deliver email messages in different formats to one or more recipients. You can learn more about the API to send email from the documentation.
Enjoy!