-->
Page 5 of 6

Re: Send email alert

PostPosted: Wed Jan 28, 2015 4:57 am
by oskar
Actually the only version that seams to be working properly is 20150126 FW.
Later firmware does not cause a reboot but just an immediate disconnect.
Could be the updates to ssl including new close sourced lib (maybe gmail doesn't like the ssl implementation) causing it?
See https://github.com/nodemcu/nodemcu-firmware/issues/134

I have tried to rebuild commenting out all "unnecessary" modules to free up some heap, but cant get it above 24 kb with 20150127 FW.

Code: Select all> node.restart()
> c_��S��FjS�fJS��C�
NodeMCU 0.9.5 build 20150126  powered by Lua 5.1.4
lua: cannot open init.lua
> print(node.heap())
24080
> dofile("gmail2.lua")
> Connected.
Logged in.
Mail sent
disconnect


> c_��RS��FjS�JS��BC�
NodeMCU 0.9.5 build 20150118  powered by Lua 5.1.4
lua: cannot open init.lua
> print(node.heap())
22688
> dofile("gmail2.lua")
> c_��RS��FjS�fJS��BC�
NodeMCU 0.9.5 build 20150118  powered by Lua 5.1.4
lua: cannot open init.lua
>

> node.restart()
> c_�RS��FS��Fj�f�C�
NodeMCU 0.9.5 build 20150127  powered by Lua 5.1.4
lua: cannot open init.lua
> print(node.heap())
22496
> dofile("gmail2.lua")
> disconnect

>

> node.restart()
> c_��RS��FjS�fJS�f�C�
NodeMCU 0.9.5_custom build 20150127  powered by Lua 5.1.4
lua: cannot open init.lua
> print(node.heap())
23944
> dofile("gmail2.lua")
> disconnect

>

Re: Send email alert

PostPosted: Wed Jan 28, 2015 9:48 pm
by diddledad
oskar wrote:Actually the only version that seams to be working properly is 20150126 FW.


Confirmed. I minimized my init.lua code and now FW 20150126 works. Thank you very much, oskar!

Code: Select all
NodeMCU 0.9.5 build 20150126  powered by Lua 5.1.4
> = node.heap()
24104
>
dofile(oskar.lua)  Wednesday, January 28, 2015  20:32:28

dofile("oskar.lua")
> Connected.
Logged in.
Mail sent
disconnect
= node.heap()
23880
>
dofile(oskar.lua)  Wednesday, January 28, 2015  20:32:37

dofile("oskar.lua")
> Connected.
Logged in.
Mail sent
disconnect
= node.heap()
23880
>


And your code with only the last line changed...

Code: Select all    conn=net.createConnection(net.TCP, 1)
    i = 1
    conn:on("receive", function(conn,payload)
       if(i==1 and string.match(payload,"220")) then
          print("Connected.")
          conn:send("EHLO\r\n")
       end
       if(i==2 and string.match(payload,"250")) then
          conn:send("AUTH LOGIN\r\n")
       end
       if (i==3 and string.match(payload,"334")) then
          conn:send("  B64username  \r\n")
       end
       if (i==4 and string.match(payload,"334")) then
          conn:send("  B64password  \r\n")
       end
       if(i==5 and string.match(payload,"235")) then
          print("Logged in.")
          conn:send("MAIL FROM: <  someone  @gmail.com>\r\n")
       end
       if(i==6) then
          conn:send("RCPT TO: <  someone  @gmail.com>\r\n")
       end
       if(i==7) then
          conn:send("DATA\r\n")
       end
       if(i==8) then
          conn:send("Subject: Test\r\n")
          conn:send("Testing email\r\n")
          conn:send(".\r\n")
       end
       if(i==9  and string.match(payload,"250")) then
          print("Mail sent")
          conn:send("quit\r\n")
       end
       i=i+1
    end)
    conn:on("disconnection", function() print("disconnect") conn=nil end)
    conn:connect(465,"smtp.gmail.com")
>

Re: Send email alert

PostPosted: Sun Feb 01, 2015 11:13 am
by diddledad
oskar,

I have loaded this code into it's own mail.lua file, uploaded it, and had my init.lua call dofile mail.lua. However, the e-mail is not sent. If I call the mail.lua file from the console using dofile, it works. So then I edited my init.lua to include the mail.lua code and deleted the mail.lua, did my restart, and the e-mail still isn't sent. I don't know why it's not working. I'm not getting restarts or anything...just nothing happens.

Have you been able to call the mail.lua file from init.lua and an e-mail get sent successfully?

My end goal is to read the state of an input pin and send an email if conditions are met.

Re: Send email alert

PostPosted: Sat Mar 07, 2015 11:50 am
by swilson
Anybody got a working init.lua and a script file that is working on gmail with LUA now for a newbie. Wanting to test some things with sending email through gmail but cannot get any of this to connect. Thanks.