LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-01-2010, 07:18 PM   #1
benjam1nrk
LQ Newbie
 
Registered: Mar 2010
Distribution: CentOS
Posts: 24

Rep: Reputation: 1
Question 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..
 
Old 04-02-2010, 08:32 AM   #2
carltm
Member
 
Registered: Jan 2007
Location: Canton, MI
Distribution: CentOS, SuSE, Red Hat, Debian, etc.
Posts: 703

Rep: Reputation: 97
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.

Last edited by carltm; 04-02-2010 at 08:34 AM. Reason: missed one line
 
Old 04-08-2010, 10:18 PM   #3
benjam1nrk
LQ Newbie
 
Registered: Mar 2010
Distribution: CentOS
Posts: 24

Original Poster
Rep: Reputation: 1
I appreciate the help. Thank you for taking the time!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] simple curl syntax doubt sl33p Linux - General 1 07-06-2009 05:18 PM
Simple pipe in deadlock? nutthick Programming 3 05-10-2006 08:59 AM
simple yet tricky pipe question rastadevil Programming 2 03-23-2006 10:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration