Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have setup a kannel SMS gateway on my FreeBSD 7.2 - the service works great.

I'm now trying to setup a email2sms feature. For this i have created a system user called kannel and all mails are forwarded to this user.

In the home dir of kannel i have the following files.

-rw-r--r--  1 kannel  kannel    81B 17 jan 09:50 .procmailrc
lrwxr-x---  1 root    kannel    58B 14 jan 13:24 email2sms.php @ -> some-what-some-where
-rw-rw-rw-  1 root    kannel   5,8K 17 jan 09:52 log.email2sms
-rw-------  1 kannel  kannel   1,3K 17 jan 09:50 procmail.log
-rw-r-----  1 root    kannel   606B 14 jan 13:28 rawmail.txt

The file email2sms.php is a symlink to the a php script (ZendFramework Application) that takes the email from STDIN, and uses ZendFramework to parse that mail into an object. It then do a http request to the SMS gateway. The php-script works.

Content of .procmailrc


| php email2sms.php >> log.email2sms

From last sent email i have this in procmail.log

procmail: [97744] Mon Jan 17 09:50:40 2011
procmail: [97744] Mon Jan 17 09:50:40 2011
procmail: Assigning "LASTFOLDER= php email2sms.php >> log.email2sms"
procmail: Executing " php email2sms.php >> log.email2sms"
procmail: Notified comsat: "kannel@:/home/user/kannel/ php email2sms.php >> log.email2sms"
From my@email.tld  Mon Jan 17 09:50:40 2011
 Subject: asdf as
  Folder:  php email2sms.php >> log.email2sms                              2600

But there is no new output to log.email2sms, and the script should output the subject of the email.

If i sudo as the kannel user and pipe a file with raw email to the script, it executes just fine.

[root@webserver /home/user/kannel]# /home/user/kannel/ sudo -u kannel cat rawmail.txt | php email2sms.php >> log.email2sms

And the command outputs to log.email2sms as desired.

Any ideas guys?


I changed the phpscript to just die('bail me out scotty'); and the script executes from .procmail when sending an email. The file log.email2smsis appended with the bail text.

So perhaps the content of the mail is not corectly piped over or the Zend Framework class that handles the piped data from STDIN is buggy.

share|improve this question
up vote 1 down vote accepted

The problem was not with procmail, but in the Zend Framework script i had.

In ZendFramework, reading email from STDIN use:

// will use file_get_contents()
$email = new Zend_Mail_Message(array('file' => "php://stdin"));

And NOT:

// will use stream_get_contents()
$email = new Zend_Mail_Message(array('file' => "STDIN"));

Note to self: Don't use tips'n'trix given in comments

share|improve this answer
BTW: kannel user needs to have a login, i had mine set to /usr/sbin/nologin – Phliplip Jan 17 '11 at 13:19

Looks like a limited shell problem, make sure the php command is in the path, also in order to debug procmail you can always add at top of the file

share|improve this answer
Already have those lines :) And i have also tried with full path to php in the .procmailrc file. What i don't understand, i can succesfully sudo the same command line as kannel. – Phliplip Jan 17 '11 at 10:02
Then you can try redirecting stderr to a file as well and see if that shows something up. php email2sms.php >> log.email2sms 2> error.log – lynxman Jan 17 '11 at 10:10
Nothing goes into to error.log – Phliplip Jan 17 '11 at 10:21
Did you actually mean 2> error.log notice the 2 - is this correct? – Phliplip Jan 17 '11 at 10:28
Look at my update in question. – Phliplip Jan 17 '11 at 10:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.