I am looking for a SIMPLE way to send an email to my email address to inform me of an event taking place using imp monitoring. Any idea?
Thanks
There is a simple looking solution using Mailgun in a recent post.
“SIMPLE” is a bit subjective. I’d suggest you take a look at GroveStreams for logging and event handling. They have a rich offering and can certainly handle this easily. They’ve posted an example of how to set up an Electric Imp with their service. I’m certainly a bit biased – a very happy customer.
Actually, if you compare Grovestream to Mailgun, they are identical in code complexity.
Mailgun:`
function sendEmailMailGun(subject, message) {
local from = MAILGUN_FROM_EMAIL;
local to = MAILGUN_TO_EMAIL;
local apikey = MAILGUN_API_KEY;
local domain = MAILGUN_DOMAIN;
local request = http.post(“https://api:” + apikey + "@api.mailgun.net/v2/" + domain + “/messages”, {“Content-Type”: “application/x-www-form-urlencoded”}, “from=” + from + “&to=” + to + “&subject=” + subject + “&text=” + message);
local response = request.sendsync();
if(response.statuscode != 200) {
server.log("Error " + response.statuscode + " sending Email message (MailGun): " + response.body );
} else {
server.log("Sent Email Door State (MailGun): " + a_currentDoorState );
}
} `
Grovestream:`
function Put(data){
local url = “https://grovestreams.com/api/feed?compId=” + data.mac;
url += “&compName=” + COMP_NAME + “+(” + data.mac + “)”;
url += “&api_key=” + API_KEY;
url += “&” + TEMP_STREAM_ID + “=” + data.temp;
url += “&” + VOLTAGE_STREAM_ID + “=” + data.voltage;
//url += “&compTmplId=template1”; //Uncomment to auto register a new component based on the template with ID=template1
local headers = { “Connection”:“close”, “X-Forwarded-For” : data.mac };
local request = http.put(url, headers, “”);
local response = request.sendsync();
if(response.statuscode != 200) {
server.log("error sending message: " + response.body);
return null;
}
}`
EDIT: I justed formatted the code to make them look more similar (no real changes)
I’m not knocking Grovestream (it looks good and because I like having options), but I would let others decide what is simpler to them. If they are already up to the task of programming an IMP, then the code above is not a huge obstacle.
The differences between the 2 sets of code above are just programming style. They both have the same requirements/complexity.