I’m an aspiring webmaster for a local food co-op. Every weekday we serve a hot lunch, which varies depending on what ingredients we have on hand and what people feel like cooking. I’ve been trying without success to add a simple feature to the website, which would allow our non-web-savvy cooks to update the website by emailing the names and ingredients of their meals. So far I have three flat-text files in the root directory of the web server, which are included into the web page using simple PHP commands. My plan is to overwrite those text files using a procmail recipe. Here’s the code I have so far.
COOPADDY=${HOME}/etc/coopaddy
:0 c
* ^TO.repasdujour
? test -f ${COOPADDY} && \
(formail -zxFrom: | fgrep -i -f ${COOPADDY})
| formail -x Subject: >/var/www/repasdujour.name
:0 A
| formail -x From: >/var/www/repasdujour.cook
:0 A
| formail -I "" >/var/www/repasdujour.zutaten
The first line tells procmail where to find a list of valid senders, so that the website is only updated if the sender is a trusted cook. Mail to the alias “repasdujour” (I translated “lunch of the day” using Babelfish) is automatically forwarded to the webmaster account by the mail server. The delivering lines are supposed to extract the subject, sender, and body of the email, saving them to the three separate text files mentioned above.
When I test this procmail script, it appears that only the contents of the From: field are correctly extracted to the desired text file. Nothing else in the /var/www directory is updated. This behavior is baffling, especially since the successful header extraction requires a match on the conditions that should have updated the file for the name of the dish.
Is the block indentation, without grouping braces, a problem for procmail? Should I have set the “c” flag on the middle recipe too? Any other ideas what might be going wrong with my code?