Page 1 of 1
Sending email in time...
Posted: Tue Nov 22, 2011 4:10 pm
by ctflatt
Hello, all.
I am developing a simple iOS/Android app that sends reminders as emailed SMS based on user preferences.
Is it possible to have the app "post" to a LC page which sends a precomposed message at a time in the future (say 45 minutes from the time it was posted)?
I currently host with On-Rev, but have no idea how to accomplish this, if it's possible.
Can anyone help guide me?
Many thanks!
:Todd
Re: Sending email in time...
Posted: Wed Nov 30, 2011 2:00 pm
by ctflatt
Either this is so simple I should be chastised for asking, or it's impossible, eh?
Anyone out there?
:Todd
PS. Klaus, thanks for cleaning up the spam... it is appreciated

Re: Sending email in time...
Posted: Wed Nov 30, 2011 6:15 pm
by bangkok
ctflatt wrote:Hello, all.
I am developing a simple iOS/Android app that sends reminders as emailed SMS based on user preferences.
Is it possible to have the app "post" to a LC page which sends a precomposed message at a time in the future (say 45 minutes from the time it was posted)?
I currently host with On-Rev, but have no idea how to accomplish this, if it's possible.
TO POST
-that's the easy part.
in your app, you put the address email for instance into leMessage. Then :
Code: Select all
put "tobeanalysed="&urlencode(leMessage) into leMessage
post leMessage to url "http://www.mysite.com/backoffice.irev
in backoffice.irev, on your on rev site :
Code: Select all
<?rev
put $_POST["tobeanalysed"] into leMessage
then, you write this information (leMessage) into a MySQL DB
TIME
-that's the tricky part from my point of view.
The only solution would be to create a "cron job"... that would execute a every XX minutes a .irev script that would read from the MySQL DB, looking for an email address.. and then sending the email, and then deleting etc.
Re: Sending email in time...
Posted: Thu Dec 01, 2011 12:29 pm
by ctflatt
bangkok:
Thank you so much for responding! I really appreciate it.
I read and understand your example, but here is the twist... I do not want to "collect" email and send once every 45 minutes, but rather when the app posts to the page, each post is sent 45 minutes later. Does that make sense?
Is this possible:
IN THE APP
Code: Select all
put "tobeanalysed="&urlencode(tMessage) into tMessage
post tMessage to url "http://www.somesite.com/backoffice.lc"
IN THE BACKOFFICE.LC FILE
Code: Select all
<?lc
put $_POST["tobeanalysed"] into tMessage
--45 minutes, converted to seconds
wait 2700 seconds with messages
post tMessage to url "http://www.somesite.com/sendmail.php"
?>
Is this viable, or is this too taxing of the server? Should this work?
Thanks!
Re: Sending email in time...
Posted: Thu Dec 01, 2011 2:03 pm
by bangkok
Ok i understand.
From my experience you can not use the form "wait for XX minutes" within a irev script.
This is why, i thought about the cron job.
Regarding your rule 45 mn after post, there is I think a turn around :
-when you receive the post, you calculate the current time + 45 mn. You write this value into the database, along with the email text to be sent.
-after that, let's say your cron job launches the second irev script every minute. Within the script, you are going to look into the database for an email with a time = + or - 1 minute compared to the current time (AKA the time when the cron job is executed).
-you send the email, then you delete it or them from the DB.
You see ?
There might be other solutions, but that's the only one i can think of.