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

Link to comment
Share on other sites

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:

 

someemail@somedomain.com 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);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.