Re: Triggering LC scripts when emails are received

2014-03-19 Thread Alex Tweedly

On 18/03/2014 09:04, j...@souslelogo.com wrote:

Then I made a test with an .irev script; the email forwarder also
detected an error in the script, but was unable to fix it, so the
test failed : the email bounced and was considered as spam.
I guess I need to follow Matthias advice and ask on-rev the path
to the LC engine on our server.


I had similar problem. Pending a reply from on-rev, I decided to be 
pragmatic and use a bit of php.


I modified my php test script to save the email to a file, and then 
trigger my LC script to operate on it.


#!/usr/bin/php -q
?
/* Read the message from STDIN */
$fd = fopen(php://stdin, r);
$email = ; // This will be the variable holding the data.
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
/* Saves the data into a file to be processed by LC */
$fdw = fopen(./mail_cache.txt, w+);
fwrite($fdw, $email);
fclose($fdw);

/* Saves the data into a file to be a permanent log */
$fdw2 = fopen(./mail_all.txt, w+);
fwrite($fdw2, $email);
fclose($fdw2);

$kick = file_get_contents('http://www.tweedly.org/testemail.lc/');
?

and then I use an ordinary LC script to deal with it. Note that when I 
change to use LC directly, it will be simple to replace the section that 
reads the mail_cache file with reading from stdin - after that  the 
processing will be unaffected.


(Here's a trimmed down version of my LC script - remember the php script 
is at the top level, but the LC script is inside an html-folder, so it 
must use an absolute path to access the shared mail-cache file)


?lc
set the errormode to inline

-- handlers for mail parsing
function parseMail pMail
   -- splits the email into the different parts (as an array)
   local K, tA, tCount, t, tStarted

   set the itemDel to :

   repeat for each line L in pMail
  if not tStarted then
 if L begins with From  then
put true into tStarted
 end if
 next repeat
  end if
  if char 1 of L = TAB then
 put CR  L after tA[K]
 next repeat
  end if
  if L contains : then
 put item 1 of L into K
 if K is among the keys of tA then
put the keys of tA[K] into t
replace CR with comma in t
put max(t) into tCount
add 1 to tCount
put item 2 to -1 of L into tA[K][tCount]
 else
put item 2 to -1 of L into tA[K]
 end if
  else
 put L  CR after tA[body]
  end if
   end repeat
   return tA
end parseMail


put URL (file:/home/myusername/mail_cache.txt) into tMail

put tMail after URL(file:./mail_handled.txt)

if tMail is empty then
  put empty at  the seconds  CR after URL (file:./lc_log.txt)
else
  put parseMail(tMail) into tAData
  put Handled at   the seconds  tAData[Message-ID] CR after 
URL (file:./lc_log.txt)

end if
put empty into URL (file:/home/myusername/mail_cache.txt)

put URL (file:./lc_log.txt)

put  
?

-- Alex.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Triggering LC scripts when emails are received

2014-03-18 Thread Matthias Rebbe | M-R-D
Hi Peter,

do you mean the livecode-server engine with „executable? I have installed it 
exactly how Runrev recommends it.
But you are right. Sensitiv data or executables should be outside public_html. 
I am already using a
special folder above public_html which contains sensitiv data like db usernames 
and passwords. So in any case
Livecode-Server engine is not running and therefore showing the complete script 
, no one can see this data except the standard script which contains the line 
with the include.

But i will try this also with the engine. Thanks for the hint.

Regards,

Matthias


Am 18.03.2014 um 06:05 schrieb Peter W A Wood peterwaw...@gmail.com:

 Hi Mattias
 
 I believe that it is safer to install executables outside the public_html 
 directory as it gives the possibility for somebody who knows how to run their 
 scripts on your server. I don't know how to do that but I have a /bin 
 directory at the same level  as public_html for executables which can be made 
 more secure.
 
 Regards
 
 Peter
 
 
 On 18 Mar 2014, at 05:50, Matthias Rebbe | M-R-D wrote:
 
 Hi jbv,
 
 Alex is right. It is working this way and believe it or not, i was also 
 working on this today.
 
 I must admit, that i use my own instances of livecode server on On-rev. 
 It is installed under public_html/cgi-bin/livecode-server502
 
 So for my configuration  i selected „Pipe to program“ and entered
 
 public_html/cgi-bin/livecode-server502/livecode-server 
 /home/MyAccountname/public_html/MyLivecodeScript.lc
 
 It does not work, if i just enter the path to the script. I have to enter 
 the path to the livecode-server engine and the complete path to the livecode 
 script.
 I do not know the paths to the preinstalled livecode-server engines on 
 On-rev, but maybe someone from the list could help. If not, i am sure On-Rev 
 support team knows
 the answer for that.
 
 Please be aware, that the script must not output anything. If it outputs 
 something, even just a space or blank line, then although the script is 
 executed the incoming mail is bounced.
 So please check your script for any blank lines or even spaces before the 
 tag ?rev and after the tag ?. It took me some hours to find out that just 
 a small
 space after the ? tag caused the incoming mails bouncing.
 
 Hope i could help.
 
 
 Regards,
 
 Matthias
 
 
 
 
 
 
 
 Am 17.03.2014 um 21:53 schrieb Alex Tweedly a...@tweedly.net:
 
 In cPanel, within the Email section, add an email forwarder.
 Fill in the adddress you want to intercept, then click on Advanced options
 Select Pipe to a program, and fill in the program script name for your 
 program
 
 NB I haven't actually done this yet !!
 
 I've been meaning to try it out for a while, just not needed it yet, and so 
 I haven't got round to trying it out - but it *should* work.
 
 I'll try it soon ... let me know if it works for you.
 -- Alex.
 
 
 On 17/03/2014 17:00, j...@souslelogo.com wrote:
 Hi list,
 
 I need to trigger LC scripts (on an on-rev account or with LC server)
 when an email is received on an email address. The address will be
 the same but email senders will vary and according to the sender's
 email, different scripts will be triggered. The idea is to process the
 content of the email with the scripts...
 I guess the trick is a server setting. Does anyone know how ?
 
 Thanks in advance.
 jbv
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your 
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your 
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Triggering LC scripts when emails are received

2014-03-18 Thread jbv
Alex  Matthias,

Thank you so much for your help.
I have made a quick test with a php script, and when I entered the
path of the php script, the mail forwarder detected a problem with
the script (it needed to be made executable) and added the following
line at the top of the script :
#!/usr/local/bin/php -q
Then everything worked fine : emails were forwarded and the php
script ran fine.

Then I made a test with an .irev script; the email forwarder also
detected an error in the script, but was unable to fix it, so the
test failed : the email bounced and was considered as spam.
I guess I need to follow Matthias advice and ask on-rev the path
to the LC engine on our server.

I have one more question though : which server global do you use
when you want to trap the content of the forwarded email (content,
senders name  email, attached docs if any...) ?

I'll keep you posted on my further tests.

Best,
jbv


 Hi jbv,

 Alex is right. It is working this way and believe it or not, i was also
 working on this today.

 I must admit, that i use my own instances of livecode server on On-rev.
 It is installed under public_html/cgi-bin/livecode-server502

 So for my configuration  i selected „Pipe to program“ and entered

 public_html/cgi-bin/livecode-server502/livecode-server
 /home/MyAccountname/public_html/MyLivecodeScript.lc

 It does not work, if i just enter the path to the script. I have to enter
 the path to the livecode-server engine and the complete path to the
 livecode script.
 I do not know the paths to the preinstalled livecode-server engines on
 On-rev, but maybe someone from the list could help. If not, i am sure
 On-Rev support team knows
 the answer for that.

 Please be aware, that the script must not output anything. If it outputs
 something, even just a space or blank line, then although the script is
 executed the incoming mail is bounced.
 So please check your script for any blank lines or even spaces before the
 tag ?rev and after the tag ?. It took me some hours to find out that
 just a small
 space after the ? tag caused the incoming mails bouncing.

 Hope i could help.


 Regards,

 Matthias







 Am 17.03.2014 um 21:53 schrieb Alex Tweedly a...@tweedly.net:

 In cPanel, within the Email section, add an email forwarder.
   Fill in the adddress you want to intercept, then click on Advanced
 options
   Select Pipe to a program, and fill in the program script name for
 your program

 NB I haven't actually done this yet !!

 I've been meaning to try it out for a while, just not needed it yet, and
 so I haven't got round to trying it out - but it *should* work.

 I'll try it soon ... let me know if it works for you.
 -- Alex.


 On 17/03/2014 17:00, j...@souslelogo.com wrote:
 Hi list,

 I need to trigger LC scripts (on an on-rev account or with LC server)
 when an email is received on an email address. The address will be
 the same but email senders will vary and according to the sender's
 email, different scripts will be triggered. The idea is to process the
 content of the email with the scripts...
 I guess the trick is a server setting. Does anyone know how ?

 Thanks in advance.
 jbv


 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode



 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Triggering LC scripts when emails are received

2014-03-18 Thread Matthias Rebbe | M-R-D
Hi jbv,

the first command i use after the ?rev is

read from stdin until EMPTY

The variable it then contains the complete email.

Regards,

Matthias

Am 18.03.2014 um 10:04 schrieb j...@souslelogo.com:

 Alex  Matthias,
 
 Thank you so much for your help.
 I have made a quick test with a php script, and when I entered the
 path of the php script, the mail forwarder detected a problem with
 the script (it needed to be made executable) and added the following
 line at the top of the script :
 #!/usr/local/bin/php -q
 Then everything worked fine : emails were forwarded and the php
 script ran fine.
 
 Then I made a test with an .irev script; the email forwarder also
 detected an error in the script, but was unable to fix it, so the
 test failed : the email bounced and was considered as spam.
 I guess I need to follow Matthias advice and ask on-rev the path
 to the LC engine on our server.
 
 I have one more question though : which server global do you use
 when you want to trap the content of the forwarded email (content,
 senders name  email, attached docs if any...) ?
 
 I'll keep you posted on my further tests.
 
 Best,
 jbv
 
 
 Hi jbv,
 
 Alex is right. It is working this way and believe it or not, i was also
 working on this today.
 
 I must admit, that i use my own instances of livecode server on On-rev.
 It is installed under public_html/cgi-bin/livecode-server502
 
 So for my configuration  i selected „Pipe to program“ and entered
 
 public_html/cgi-bin/livecode-server502/livecode-server
 /home/MyAccountname/public_html/MyLivecodeScript.lc
 
 It does not work, if i just enter the path to the script. I have to enter
 the path to the livecode-server engine and the complete path to the
 livecode script.
 I do not know the paths to the preinstalled livecode-server engines on
 On-rev, but maybe someone from the list could help. If not, i am sure
 On-Rev support team knows
 the answer for that.
 
 Please be aware, that the script must not output anything. If it outputs
 something, even just a space or blank line, then although the script is
 executed the incoming mail is bounced.
 So please check your script for any blank lines or even spaces before the
 tag ?rev and after the tag ?. It took me some hours to find out that
 just a small
 space after the ? tag caused the incoming mails bouncing.
 
 Hope i could help.
 
 
 Regards,
 
 Matthias
 
 
 
 
 
 
 
 Am 17.03.2014 um 21:53 schrieb Alex Tweedly a...@tweedly.net:
 
 In cPanel, within the Email section, add an email forwarder.
  Fill in the adddress you want to intercept, then click on Advanced
 options
  Select Pipe to a program, and fill in the program script name for
 your program
 
 NB I haven't actually done this yet !!
 
 I've been meaning to try it out for a while, just not needed it yet, and
 so I haven't got round to trying it out - but it *should* work.
 
 I'll try it soon ... let me know if it works for you.
 -- Alex.
 
 
 On 17/03/2014 17:00, j...@souslelogo.com wrote:
 Hi list,
 
 I need to trigger LC scripts (on an on-rev account or with LC server)
 when an email is received on an email address. The address will be
 the same but email senders will vary and according to the sender's
 email, different scripts will be triggered. The idea is to process the
 content of the email with the scripts...
 I guess the trick is a server setting. Does anyone know how ?
 
 Thanks in advance.
 jbv
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Triggering LC scripts when emails are received

2014-03-17 Thread jbv
Hi list,

I need to trigger LC scripts (on an on-rev account or with LC server)
when an email is received on an email address. The address will be
the same but email senders will vary and according to the sender's
email, different scripts will be triggered. The idea is to process the
content of the email with the scripts...
I guess the trick is a server setting. Does anyone know how ?

Thanks in advance.
jbv


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Triggering LC scripts when emails are received

2014-03-17 Thread Alex Tweedly

In cPanel, within the Email section, add an email forwarder.
   Fill in the adddress you want to intercept, then click on Advanced 
options
   Select Pipe to a program, and fill in the program script name for 
your program


NB I haven't actually done this yet !!

I've been meaning to try it out for a while, just not needed it yet, and 
so I haven't got round to trying it out - but it *should* work.


I'll try it soon ... let me know if it works for you.
-- Alex.


On 17/03/2014 17:00, j...@souslelogo.com wrote:

Hi list,

I need to trigger LC scripts (on an on-rev account or with LC server)
when an email is received on an email address. The address will be
the same but email senders will vary and according to the sender's
email, different scripts will be triggered. The idea is to process the
content of the email with the scripts...
I guess the trick is a server setting. Does anyone know how ?

Thanks in advance.
jbv


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Triggering LC scripts when emails are received

2014-03-17 Thread Matthias Rebbe | M-R-D
Hi jbv,

Alex is right. It is working this way and believe it or not, i was also working 
on this today.

I must admit, that i use my own instances of livecode server on On-rev. 
It is installed under public_html/cgi-bin/livecode-server502

So for my configuration  i selected „Pipe to program“ and entered

public_html/cgi-bin/livecode-server502/livecode-server 
/home/MyAccountname/public_html/MyLivecodeScript.lc

It does not work, if i just enter the path to the script. I have to enter the 
path to the livecode-server engine and the complete path to the livecode script.
I do not know the paths to the preinstalled livecode-server engines on On-rev, 
but maybe someone from the list could help. If not, i am sure On-Rev support 
team knows
the answer for that.

Please be aware, that the script must not output anything. If it outputs 
something, even just a space or blank line, then although the script is 
executed the incoming mail is bounced.
So please check your script for any blank lines or even spaces before the tag 
?rev and after the tag ?. It took me some hours to find out that just a small
space after the ? tag caused the incoming mails bouncing.

Hope i could help.


Regards,

Matthias







Am 17.03.2014 um 21:53 schrieb Alex Tweedly a...@tweedly.net:

 In cPanel, within the Email section, add an email forwarder.
   Fill in the adddress you want to intercept, then click on Advanced options
   Select Pipe to a program, and fill in the program script name for your 
 program
 
 NB I haven't actually done this yet !!
 
 I've been meaning to try it out for a while, just not needed it yet, and so I 
 haven't got round to trying it out - but it *should* work.
 
 I'll try it soon ... let me know if it works for you.
 -- Alex.
 
 
 On 17/03/2014 17:00, j...@souslelogo.com wrote:
 Hi list,
 
 I need to trigger LC scripts (on an on-rev account or with LC server)
 when an email is received on an email address. The address will be
 the same but email senders will vary and according to the sender's
 email, different scripts will be triggered. The idea is to process the
 content of the email with the scripts...
 I guess the trick is a server setting. Does anyone know how ?
 
 Thanks in advance.
 jbv
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Triggering LC scripts when emails are received

2014-03-17 Thread Peter W A Wood
Hi Mattias

I believe that it is safer to install executables outside the public_html 
directory as it gives the possibility for somebody who knows how to run their 
scripts on your server. I don't know how to do that but I have a /bin directory 
at the same level  as public_html for executables which can be made more secure.

Regards

Peter


On 18 Mar 2014, at 05:50, Matthias Rebbe | M-R-D wrote:

 Hi jbv,
 
 Alex is right. It is working this way and believe it or not, i was also 
 working on this today.
 
 I must admit, that i use my own instances of livecode server on On-rev. 
 It is installed under public_html/cgi-bin/livecode-server502
 
 So for my configuration  i selected „Pipe to program“ and entered
 
 public_html/cgi-bin/livecode-server502/livecode-server 
 /home/MyAccountname/public_html/MyLivecodeScript.lc
 
 It does not work, if i just enter the path to the script. I have to enter the 
 path to the livecode-server engine and the complete path to the livecode 
 script.
 I do not know the paths to the preinstalled livecode-server engines on 
 On-rev, but maybe someone from the list could help. If not, i am sure On-Rev 
 support team knows
 the answer for that.
 
 Please be aware, that the script must not output anything. If it outputs 
 something, even just a space or blank line, then although the script is 
 executed the incoming mail is bounced.
 So please check your script for any blank lines or even spaces before the tag 
 ?rev and after the tag ?. It took me some hours to find out that just a 
 small
 space after the ? tag caused the incoming mails bouncing.
 
 Hope i could help.
 
 
 Regards,
 
 Matthias
 
 
 
 
 
 
 
 Am 17.03.2014 um 21:53 schrieb Alex Tweedly a...@tweedly.net:
 
 In cPanel, within the Email section, add an email forwarder.
  Fill in the adddress you want to intercept, then click on Advanced options
  Select Pipe to a program, and fill in the program script name for your 
 program
 
 NB I haven't actually done this yet !!
 
 I've been meaning to try it out for a while, just not needed it yet, and so 
 I haven't got round to trying it out - but it *should* work.
 
 I'll try it soon ... let me know if it works for you.
 -- Alex.
 
 
 On 17/03/2014 17:00, j...@souslelogo.com wrote:
 Hi list,
 
 I need to trigger LC scripts (on an on-rev account or with LC server)
 when an email is received on an email address. The address will be
 the same but email senders will vary and according to the sender's
 email, different scripts will be triggered. The idea is to process the
 content of the email with the scripts...
 I guess the trick is a server setting. Does anyone know how ?
 
 Thanks in advance.
 jbv
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your 
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode