Tried to pass the commands as an array which made it run out of heap, also adding checks on all ifs or even putting the sends in a separate function makes it run out of heap and restart the module.
So a a quick and dirty way to send mail through gmail smtp. Do a node.restart() before the dofile since you need as much RAM as you can get.
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("username\r\n")
end
if (i==4 and string.match(payload,"^334")) then
conn:send("password\r\n")
end
if(i==5 and string.match(payload,"^235")) then
print("Logged in.")
conn:send("MAIL FROM: <xxx@gmail.com>\r\n")
end
if(i==6) then
conn:send("RCPT TO: <yyy@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("Test\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,"64.233.164.108")