PK
¢y#F F scripts/Gmail_SMTP.js/*************************
To allow this script to send commands via your gmail account,
you need to give an access to the account to unreliable applications:
https://www.google.com/settings/security/lesssecureapps
or send a first email: you'll receive an attention message about unreliable application.
Allow the access for unreliable applications and it is done, you can send a messages from iRidium using this email address
!!! we recommend you to create a new emaila address to be sure your main email is secured enough and don't used by unreliable applications !!!
*************************
Format of command needed to send the email:
send_email (name_from, email_from, password, email_to, header, message)
name_from - name of email sender
email_from - email of your Gmail account
password - password of your Gmail account
email_to - email of message receiver (any domain)
header - message header
message - message text (text only)
send_email("Smart Home", "iridium.notification@gmail.com", "********", "tech@iridiummobile.ru", "Attention", "Message text")
You can send this command by any event in the system, just copy the command string with needed settings
*************************/
var smtp_driver = IR.CreateDevice(IR.DEVICE_CUSTOM_TCP, "SMTP", { // create Telnet connection with Google SMTP server
Host: "smtp.gmail.com",
Port: 465,
SSL: true,
SendMode: IR.ALWAYS_CONNECTED,
ScriptMode: IR.SCRIPT_ONLY
});
function send_email (name_from, email_from, password, email_to, header, message)
{
IR.AddListener(IR.EVENT_RECEIVE_TEXT, smtp_driver, sender); // listen for server answer
send("hello"); // send hello and login when start the communication with server
send("auth");
function send(command)
{
IR.Log(">>>>"+command);
switch (command) // list of smtp commands
{
case "hello":
smtp_driver.Send(["EHLO smtp.gmail.com\r\n"]);
break;
case "auth":
smtp_driver.Send(["AUTH LOGIN\r\n"]);
break;
case "login":
smtp_driver.Send([IR.Base64Encode(email_from) + "\r\n"]);
break;
case "password":
smtp_driver.Send([IR.Base64Encode(password) + "\r\n"]);
break;
case "from":
smtp_driver.Send(["MAIL FROM:<"+email_from+">\r\n"]);
break;
case "to":
smtp_driver.Send(["RCPT TO:<"+email_to+">\r\n"]);
break;
case "data":
smtp_driver.Send(["DATA\r\n"]);
break;
case "string":
smtp_driver.Send(["From: "+name_from+" <"+email_from+">\r\nTo:<"+email_to+">\r\nSubject: "+header+"\r\nContent-Type: text/plain\r\n\r\n"+message+"\r\n.\r\n"]);
break;
case "quit":
smtp_driver.Send(["QUIT\r\n"]);
break;
}
}
function sender(text)
{
IR.Log(text);
var auth = text.indexOf("334 VXN", 0) + 1;
var accepted = text.indexOf("Accepted", 0) + 1;
var sent_ok = text.indexOf("250 2.1.5 OK", 0) + 1;
var uncat_cmd = text.indexOf("502 5.5.1 Unrecognized command", 0) + 1;
if(auth) // if authorization needed, send login and password
{
send("login");
send("password");
}
if(accepted) // when authorization confirmed, send a message
{
send("from");
send("to");
send("data");
send("string");
}
if(uncat_cmd)
{
IR.Log("message error!");
//send("quit");
IR.RemoveListener(IR.EVENT_RECEIVE_TEXT, smtp_driver, sender); // disconnect from server when the message sent
}
if(sent_ok)
{
IR.Log("OK, disconnecting...");
send("quit");
IR.RemoveListener(IR.EVENT_RECEIVE_TEXT, smtp_driver, sender); // disconnect from server when the message sent
}
}
}PK
fí9ÔÖ Ö scripts/Gmail_SMTP_sample.js/*************************
To allow this script to send commands via your gmail account,
you need to give an access to the account to unreliable applications:
https://www.google.com/settings/security/lesssecureapps
or send a first email: you'll receive an attention message about unreliable application.
Allow the access for unreliable applications and it is done, you can send a messages from iRidium using this email address
!!! we recommend you to create a new emaila address to be sure your main email is secured enough and don't used by unreliable applications !!!
*************************
Format of command needed to send the email:
send_email (name_from, email_from, password, email_to, header, message)
name_from - name of email sender
email_from - email of your Gmail account
password - password of your Gmail account
email_to - email of message receiver (any domain)
header - message header
message - message text (text only)
send_email("Smart Home", "iridium.notification@gmail.com", "********", "tech@iridiummobile.ru", "Attention", "Message text")
You can send this command by any event in the system, just copy the command string with needed settings
*************************/
function try_to_send ()
{
send_email("AUTHOR-OF-MESSAGE", "YOUR-MAIL@gmail.com", "YOUR_PASS", "WHERE-TO-SEND@gmail.com", "HEADER-OF-MESSAGE", "TEXT-OF-MESSAGE")
}
PK
¨²
M M Project.irp
PK
‡ã'Ï€ €
Config.xml
PK
¢y#F F scripts/Gmail_SMTP.jsPK
fí9ÔÖ Ö y scripts/Gmail_SMTP_sample.jsPK
¨²
M M ‰ Project.irpPK
‡ã'Ï€ €
ÿ Config.xmlPK þ §