LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Simple Pipe Email to Curl (https://www.linuxquestions.org/questions/linux-newbie-8/simple-pipe-email-to-curl-799465/)

benjam1nrk 04-01-2010 07:18 PM

Simple Pipe Email to Curl
 
I would like to pipe a raw email from cPanel to curl, using curl to send the raw email via a post variable. However, I am unsure of the command line syntax that would receive the piped email and post using curl.

Ideally, the email would pipe to the curl command "curl -d 'emailvar=RAWEMAILHERE' https://mysite.com/myscript.php", where RAWEMAILHERE would be the email message.

Can anyone please help me with the command line required to accomplish this? Thanks in advance..

carltm 04-02-2010 08:32 AM

First, create a new user account to handle these messages.

In the user's home directory, add this to .forward, replacing the UserName with the actual username:
"|/etc/smrsh/mailcmd || exit 75 #UserName"

Run this snippet of code:
Code:

cat > /usr/local/sbin/mailcmd <<\EoT
#!/bin/sh
Message="`cat`"
if echo "$Message" | grep "..." > /dev/null; then
  echo "$Message" | formail -I "" > /tmp/mailcmd
fi
EoT
chmod 755 /usr/local/sbin/mailcmd
ln -s /usr/local/sbin/mailcmd /etc/smrsh

Next, test that email sent to this user actually creates a file in /tmp. When you have that
working, the next step is to replace the ... with a string to find valid messages. Test to
make sure valid messages create files in /tmp, but other messages do not. Then you can replace
the file creation command with the command you actually want to run.

benjam1nrk 04-08-2010 10:18 PM

I appreciate the help. Thank you for taking the time!


All times are GMT -5. The time now is 10:08 PM.