Message:

Subscribe rss
Blog categories
All | Backendless features
Feature 34: Sending email from your mobile, browser or desktop app
February 10, 2015 by markpiller
Spread the love

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:

Asynchronous sample (Plain Java and Android):

Synchronous sample (Plain Java only):

The code above sends an HTML-formatted email to one recipient. You can also create an array of email addresses and use it 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:

  1. Login to Backendless console, select your app and click the Manage icon.
  2. Scroll down to the Email Settings section.
  3. Enter the name you would like to use in the emails sent out by Backendless. Also enter the email address (which is the userid) and password used to authenticate against the SMTP server. Before you save the data, click the Test button to validate the credentials.
  4. Click the Save button to save the new settings.

Below is a screenshot of the settings after I made the changes described above:
email settings - Feature 34: Sending email from your mobile, browser or desktop app

Now when I run the same code, I get the following output:

When the email arrives, it looks exactly as expected – an HTML-formatted email:
delivered email - Feature 34: Sending email from your mobile, browser or desktop app

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!

Share this post
Tweet about this on TwitterShare on FacebookGoogle+