fallguy Posted June 21, 2009 Share Posted June 21, 2009 Hello, This is my post here, so I'll try to remain this clean and concise I'm using a .forward file to forward email to a shell script in order to parse out the Subject and Body for later use. It's important that I use a shell script here, rather than perl or another language. After receiving the Subject and Body, I'm trying to forward these to a php script on an external server via curl. However, when I send an email the php script does not receive the Subject and Body. I believe the problem may be with curl, because when I run a simulated email through parse.sh, via cat test.txt | ./parse.sh, both the Subject and Body are properly returned. Here is the content of the .forward file, located at /home/Dave/: |/home/Dave/parse.sh The content of the shell script (parse.sh) is attached. Is the curl command that I'm using not formatted correctly, and/or is there any error is my methods used to parse the Subject and Body? Any help would be appreciated. --Thanks [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/163070-problem-with-shell-script-when-parsing-email/ Share on other sites More sharing options...
trq Posted June 21, 2009 Share Posted June 21, 2009 Can you just post your code? I don't download zip files. Link to comment https://forums.phpfreaks.com/topic/163070-problem-with-shell-script-when-parsing-email/#findComment-860459 Share on other sites More sharing options...
fallguy Posted June 21, 2009 Author Share Posted June 21, 2009 Thanks for the response. On a side note, this seems to be working on my local setup when running a test, such as echo "Subject: 19800131 Body.." | ./parse.sh. The script.php at the end, however, is failing to recognize the post variables. #!/bin/bash in=`fold -s -w 64` BODY=`echo "$in" | sed -n 'H;${g;s/.*\n\n\(.*\)/\1/g;p}'` BODY=$(echo -n "$BODY" | \ perl -pe's/([^-_.~A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg'); SUBJECT=`echo "$in" | grep -m1 -i 'Subject:.*[0-9]\{8\}.*' | \ sed 's/^Subject:\(.*\)$/\1/'` SUBJECT=$(echo -n "$SUBJECT" | \ perl -pe's/([^-_.~A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg'); curl -s -d "subject=${SUBJECT}&body=${BODY}" http://www.domain.com/script.php exit 0 Link to comment https://forums.phpfreaks.com/topic/163070-problem-with-shell-script-when-parsing-email/#findComment-860498 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.