SMTP Help

Hi. So I’m having problems using SMTP.

Right now I’m following this reference:
http://w3.impa.br/~diego/software/luasocket/old/luasocket-2.0-beta/smtp.html

Here is my current code.

[code]
– load the smtp support
local smtp = require (“smtp”)

from = ""

rcpt = {
“”,
}

mesgt = {
headers = {
to = "xxxxxxx ",
subject = “Hello”
},
body = “Testing 123”
}

r, e = smtp.send{
from = from,
rcpt = rcpt,
source = smtp.message(mesgt),
user = “xxxxxxx”,
password = “xxxxxxx”,
server = “smtp.gmail.com”,
port = “465”,
}
[/code]

I have all the files (smtp.lua, ltn12.lua, mime.lua, and tp.lua) from the LuaSocket library copied into my project folder.

Right now I’m getting the following error message:

Runtime error: …/main.lua:24: attempt to index local ‘smtp’ (a boolean value)


Would anyone be able to walk me through this? Or possible point me in the right direction? I’d appreciate any help! Thank you!

[import]uid: 19931 topic_id: 7443 reply_id: 307443[/import]

Oh, I actually edited the code a little bit (deleting comments, nothing too vital) before submitting it. So the error is actually caught at line 18 (as shown) not 24. [import]uid: 19931 topic_id: 7443 reply_id: 26356[/import]

The Corona build process packages the required LuaSocket libraries at build time. The ones in your project folder may be conflicting with those, causing the error. Try removing all the socket libraries from your project folder and build again (you will likely need to test on a device, since I’m not sure if the simulator supports SMTP.)

Tim [import]uid: 8196 topic_id: 7443 reply_id: 26359[/import]

Thank you for your advice, Tim.

Ok. So I deleted the libraries from my project folder and build the project again, but now I’m receiving error about missing files.

Do I need to adjust the following line?

local smtp = require ("smtp")

i’m not sure gmail works with POP3 anymore. if it does it needs https which i’m not sure is working with corona yet.

I had the same problem…

instead, set yourself up a test account on http://www.gmx.com and try your example with their smtp server (smtp.gmx.com) instead using your gmx user/pass

mentioned here:
http://developer.anscamobile.com/forum/2011/01/31/uploading-binary-file-http#comment-19806

i think the specific issue i had was with gmail’s required setting in the second line here

Configure Gmail SMTP port as: 465 or 587  
Configure Gmail SMTP TLS/SSL required as: yes  

j
[import]uid: 6645 topic_id: 7443 reply_id: 26361[/import]

Thanks for the input. Totally overlooked that.

How were you able to work with SMTP in your app? I keep getting error messages when I try to build my project. [import]uid: 19931 topic_id: 7443 reply_id: 26364[/import]

all the socket functions are built in to Corona. you dont want an smtp.lua file in your folder, just like you dont have a physics.lua

[import]uid: 6645 topic_id: 7443 reply_id: 26367[/import]

Ok. So I was finally able to get it to build without any error messages. I had to adjust the first line to

local smtp = require ("socket.smtp")

I set up a gmx account. And adjusted the server settings in my code.

I uploaded the program onto my phone - but no email is sent. Is there something else I might be overlooking? [import]uid: 19931 topic_id: 7443 reply_id: 26795[/import]

Yay! It actually did the send. The email just took a while to go through. Thanks for your help everyone! [import]uid: 19931 topic_id: 7443 reply_id: 26801[/import]

Ah. I realized I spoke too soon. The emails that were sent were actually from running the simulator. Apparently it does support SMTP. The application on my phone will not successfully send the email. Is there something I have overlooked? Thanks! [import]uid: 19931 topic_id: 7443 reply_id: 26814[/import]

Could we please get a confirmation from Ansca whether the integrated LuaSocket library supports SSL for SMTP?

(My guess is not, as I cannot get it to connect with gmail on port 465 and there is no explicit way to specify SSL for the connection… and the official luasocket-smtp webpage (http://w3.impa.br/~diego/software/luasocket/smtp.html) doesn’t even mention ssl)

Note that if there is no SSL support… this SMTP module is pretty useless…

-FrankS
[import]uid: 8093 topic_id: 7443 reply_id: 30766[/import]

is there ssl support or not? [import]uid: 19590 topic_id: 7443 reply_id: 63618[/import]

Does someone know if this is included in Corona or if this can be included?

http://barracudaserver.com/ba/doc/en/lua/auxlua.html [import]uid: 19590 topic_id: 7443 reply_id: 63757[/import]

LuaSocket that is built into Corona does NOT support SSL. The Async APIs (network.request and network.download) support SSL but don’t support the low-level LuaSocket functionality. [import]uid: 7559 topic_id: 7443 reply_id: 63818[/import]

Tom,

Thank you for the answer.
I want to give a +1 to feature: mail with attachment.

regards,

Jürgen

ps: email sending with attachments etc works ok, but without tls/ssl, so since it is a business app, this is a security issue. [import]uid: 19590 topic_id: 7443 reply_id: 63830[/import]