What Web Service for eMailing from Smart Apps?

I need to send through email, statistics and alerts from a Smart App (using httpget).
I tried to open an account with SendGrid.com, but their account validation process is a pain, and they seem to reject individuals.
I only need to send a few emails per day, and the most intensive mailing will be during testing.

Does anybody have some free alternative ?

Too bad SmartThings does not provide an email http server, as they do for SMS…

Have you looked at Mandrill?

Yeah, yet another reason for raw socket support and parsing replies… Could just do it native in a devicetype to send email using a hubaction… Maybe someday.

For now, you will have to find a relay service…



All seem to have some level of “free” but I’d test them if I were you…

You can also try IFTTT.


You could also set up a Google voice/sms acct with a keyword rule that forwards to any email. Crockpot uses that to tweet.

1 Like

@Tyler, @pstuart, @NickW : thanks a lot to all of you, I will try one of those.

@wackware : a relay through SMS would not work, due to limitation of SMS size :
what I am trying to do is to download once a week a large history file of events from a Smart App to a PC, for further processing.
And the 160 characters of a SMS are definitely too small…

One year ago, I spent quite some time integrating a Mandrill call into my SmartApps, but the free transactional email service offered by Mandrill will be discontinued by April 27, and then cost $360/year, even when sending less than 100 emails !.
I find that price change abusive and would like to migrate to an other free/cheap email web service.
But considering the large time it took me last time to set up the Mandrill call within my SmartApp, I was wondering which email web service would need the less work for that migration, preferably using the same SmartThings call (httpPostJson () ).

=> Anybody who already got such an experience ?

It is a real shame a basic email web service is not part of the SmartThings platform, since it is the simplest interface when you want to dump some historical data (last 5 days temperatures measurements in my case) for further processing.

Well, getting no answer from the community, nor from SmartThings support, I finally found by myself a way to substitute Mailjet to Mandrill.
I used Mandrill for free during 18 months, was mostly satisfied with it, but having now to pay $540/year to send 200 emails/year was definitely excessive.
Mailjet allows you to send a maximum of 6 000 emails/months for free, which is more than enough for my needs.
And its interface is also based on JSON, which facilitates the migration from Mandrill.

To send emails from your SmartApp you will need :

  1. to create a Mailjet free account
  2. to get from Mailjet your own pair of USERNAME (API KEY) and PASSWORD (SECRET KEY)
  3. to validate your sender email address (or more than one)
  4. to replace all ‘$$’ instances in the example below with your own values

Sadly, SmartThings does not seem interested in providing a built-in email capability for SmartApps, which would save people needing such function lots of grief…
Hope this helps some of you to save the multiple hours I wasted first to integrate Mandrill, then to do it again with Mailjet :slight_smile:

def sendTestEmail() {
	log.debug "sendTestEmail()............."
        def theText = "Non HTML text message"
    	def fileContent = "attached file body"
        def encoded64 = (String) fileContent.bytes.encodeBase64(true)  // (true) required for 76 characters line splitting
        def theSubject = "Test email sent from SmartApp"
    	sendEmail(encoded64, theSubject, theText)

 * Mailjet API Documentation :
 *		http://dev.mailjet.com/guides/?shell#send-transactional-email
 *		http://dev.mailjet.com/guides/?shell#send-api-json-properties
 * JsonBuilder Documentation :
 *		http://groovy.codehaus.org/gapi/groovy/json/JsonBuilder.html <- buggy example
 *		http://jsonlint.com/
 * hpptPostJson() SmartThings Documentation :
 *		http://docs.smartthings.com/en/latest/ref-docs/smartapp-ref.html#smartapp-http-post-json
 * Note : 'attachedContent' input is supposed to already be Base64 encoded
def sendEmail(String attachedContent, theSubject, theText) {
    def builder = new groovy.json.JsonBuilder()
	def root = builder(
        	'Text-part': theText,
        	Subject: theSubject,
        	FromEmail: '$$yourSenderAdress@$$yourDomain',
        	FromName: '$$yourSenderName',
        	Recipients: [
 				Email: '$$email1@$$Domain1',
				Name: '"$$email1Name"',
				Type: 'to'
 				Email: '$$email2@$$Domain2',
				Name: '"$$email2Name"',
				Type: 'to'
			Headers: [
            	'Reply-To': 'donotreply@$$yourDomain'
        	Attachments: [[
                'Content-type': 'text/plain',
                Filename: 'myfile.txt',
                binary: true,	// ignored by Mailjet ?
                //content: 'YmxhYmxhYmxh' // : "blablabla" Base64 encoded
                content: attachedContent
	//assert root instanceof Map
	def jsonBody = builder.toString()

	def successClosure = { response ->
		log.debug "eMail sent, response : ${response}"

	def params = [
		uri: "https://$$mailJetAPIKey:$$mailJetSecretKey@api.mailjet.com/v3/send", // +postParameters,
		success: successClosure,
		body: jsonBody
	return httpPostJson(params)

Thank you for this!! I was using PushingBox, but had some format issues and while it works, it almost seems like its a dead end. I was able to get this to do all I need.
Thanks again!!

@mpenda : you are welcomed :slight_smile:
Beware however that sending only once to a single email address is NOT reliable : sometimes the message arrives, sometimes not.
Unfortunately, the SmartApp sending the email through Mailjet is not aware of the problem (or I missed how to check correct final delivery with Mailjet, if there is any way).
I have not been able to track down the ultimate cause of that, but I suspect it is because the shared Mailjet SMTP sending servers are regularly blacklisted by some of the destination domains POP3 receiving servers.
I used a dumb workaround : I am sending duplicated emails to 3 different addresses within 3 different domains (ex : xxx@google.com + yyy@yahoo.com + zzz@orange.com) and up to now I have always received at least ONE of them.

So far, so good. But Its only been a couple of days. Given the nature of what Mailjet does, blacklisting seems the most likely. You can try also sending to Pushingbox as a means of debugging. Not that hard to setup.
Have you tried to do any HTML in the messages?

I am basically using those emails to download temperature snapshots history before SmartThings erases them (after 7 days), so I had no need for HTML.
But since HTML is nothing more than TEXT with inline markup, I do not see why there would be any problem.

That’s funny, that’s my primary usage of this…sending sensor readings!! But no, html is not that simple I’m afraid, it has to go in MIME format somehow. The HTML tags just come through as the text of the tags. I’ll keep poking around with this from time to time…

Also, you probably know this, but you can connect to GroveStreams to gather and plot sensor data…