Jump to content

PHP script which will send SMS using API once new email arrive


ankur0101

Recommended Posts

Hi everybody,

I want to create a script which will send SMS on a number once new mail arrives in email account.

I have SMS API service from http://www.freesmsapi.com/

I am using cPanel, but how to do it ?

One idea is, new mails are stored in "new" folder and already read mails are stores in "cur".

So once, new email file will come in "new" folder PHP script will see that file and will send SMS, with text as

"Hi, {user}, you gotta mail from {sender}, subject is {sibject}"

 

That PHP file will be added to Cronjobs. But how to do it ?

I have been searching on this issue from many months, did google but no answer.

 

I need help

picked this up from http://bytes.com/topic/php/answers/3651-email-trigger-php-function

 

Do this: (i know guys, there are other ways to do it with procmailrc, but

most people mess that file up)

 

in /etc/mail/virtusertable:

 

[email protected] aliasScriptName

 

 

then in /etc/alaises

 

aliasScriptName "| /etc/smrsh/scriptname"

 

 

 

then in /etc/smrsh/scriptname

 

#!/usr/bin/php -q

<?php
// read from stdin
$fd = fopen("php://stdin", "r");
while (!feof($fd))
{
$inData = fgets($fd, 1024);
$inData = trim($inData);

.. proccess $inData here ...

}
fclose($fd);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.