1

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

LOGFILE=$HOME/procmail.log VERBOSE=yes :0 | 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 [email protected] 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?

UPDATE

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.

2 Answers 2

1

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

1
  • BTW: kannel user needs to have a login, i had mine set to /usr/sbin/nologin Commented Jan 17, 2011 at 13:19
0

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

LOGFILE=$HOME/procmail.log VERBOSE=on 
5
  • 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. Commented Jan 17, 2011 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 Commented Jan 17, 2011 at 10:10
  • Nothing goes into to error.log Commented Jan 17, 2011 at 10:21
  • Did you actually mean 2> error.log notice the 2 - is this correct? Commented Jan 17, 2011 at 10:28
  • Look at my update in question. Commented Jan 17, 2011 at 10:43

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.