PK
f9s s 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)
{
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)
{
if(text.indexOf("334 VXN", 0) + 1) // if authorization needed, send login and password
{
send("login");
send("password");
}
if(text.indexOf("Accepted", 0) + 1) // when authorization confirmed, send a message
{
send("from");
send("to");
send("data");
send("string");
IR.SetTimeout(200, function () {send("quit"); IR.RemoveListener(IR.EVENT_RECEIVE_TEXT, smtp_driver, sender); IR.Log("message sent");}); // disconnect from server when the message sent
}
//IR.Log(text);
}
}PK
\Þèj j 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("From Smart Home", "******@gmail.com", "your_password", "destinationaddress@anydomain.com", "Header of message", "Text of message")
You can send this command by any event in the system, just copy the command string with needed settings
*************************/
function try_to_send () // function related with Server tag, you can send a message via Server web-interface, just activate a "Send email" token
{
send_email("From Smart Home", "******@gmail.com", "your_password", "destinationaddress@anydomain.com", "Header of message", "Text of message")
}
PK
ò¢lÅL L Project.irp
PK
‡ã'Ï€ €
Config.xml
PK
f9s s scripts/Gmail_SMTP.jsPK
\Þèj j ¦ scripts/Gmail_SMTP_sample.jsPK
ò¢lÅL L J Project.irpPK
‡ã'Ï€ €
¿ Config.xmlPK þ g