How to use Sarah's SMTP library demo

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Nana
Posts: 38
Joined: Sat Aug 11, 2012 8:01 pm

How to use Sarah's SMTP library demo

Post by Nana » Sat Aug 11, 2012 11:00 pm

Hi,

i am trying to make an android application that sends email to a specific email address. I want to send emails by pressing one button without opening the user's default email program so revMail is not a good solution. I found that Sarah's SMTP library demo do this but i don't know how to use it. I am very newbie in LiveCode so can someone explain me how to use this demo? I try to put on the server the smtp. gmail. com but it doesn't work. Any help would be appreciate.

Thanks in advance.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: How to use Sarah's SMTP library demo

Post by sturgis » Sat Aug 11, 2012 11:57 pm

I haven't used Sarah's smtp library but I know it uses sockets, and sockets are not yet available on Android. Meaning until that happens it won't work on android at all. It is possible it could be modified to work with IOS if you build the rresockets external (which is part of the externals building tutorial stuff) but there is no externals sdk for android yet either so you can't roll your own socket external there.

If you have access to a server where you can host a cgi script you can probably post data to the server and have it relay the email for you.

Nana
Posts: 38
Joined: Sat Aug 11, 2012 8:01 pm

Re: How to use Sarah's SMTP library demo

Post by Nana » Sun Aug 12, 2012 11:08 am

How can i do it to send automatically the email by pressing one button on android? Is there any tutorial or an example to help me?

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: How to use Sarah's SMTP library demo

Post by shaosean » Sun Aug 12, 2012 11:55 am

No work on Andriod

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: How to use Sarah's SMTP library demo

Post by sturgis » Sun Aug 12, 2012 1:11 pm

If you have access to a web server you can probably find a pre-built php script that you can use to catch posted data and send the email. The server side I can't help you with. I haven't set up an email form/cgi emailer myself but there are a ton available out there.

To actually get the data to the server look at post in the dicionary. Since libUrlFormData is not yet available for android/ios you need to build your post string by hand.

You will want to end up with a string that looks like this
"to=address@example.com&subject=the subject goes here..." you get the idea.
The main thing is that the item to the left of each = must match what the receiving script is expecting so that it knows what to do with each item.

You will also probably need to not have spaces (or certain special chars) in the string. So for example if you have a variable "tSubject" that contains "this is my subject" you will most likely want to use urlencode() on it.

put urlencode(tSubject) into tSubject This will take the above example of "the subject goes here..." and change it to "the+subject+goes+here..." You will want to decode it on the far end so be aware that it will encode more than just spaces. For what you are doing it is possible that you can get away with ONLY encoding spaces so you could always just use replace (replace space with "[space]" then on the far end put the space back in by replacing [space] in the string.

Once you get a valid post string put together you can
post tMyData to URL "http://whatever.address.com/the/email/script.php" -- the data will be sent, and

Nana
Posts: 38
Joined: Sat Aug 11, 2012 8:01 pm

Re: How to use Sarah's SMTP library demo

Post by Nana » Sun Aug 12, 2012 3:13 pm

Thank you very much sturgis you were very helpful i did it and it work fine. Thank you!

Post Reply