From 0caaea6c04f3e46b67ca0fa3af8d4a699de08ddb Mon Sep 17 00:00:00 2001
From: Jake Bell <jake@theunraveler.com>
Date: Thu, 19 Jan 2012 13:52:39 -0600
Subject: [PATCH] Changing drush command so that it accepts the email message
 from STDIN, rather than creating a tempfile.

---
 femail.drush.inc      |    5 ++---
 femail_procmail_drush |   11 +++--------
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/femail.drush.inc b/femail.drush.inc
index 22a904f..ec38cc6 100644
--- a/femail.drush.inc
+++ b/femail.drush.inc
@@ -17,8 +17,7 @@ function femail_drush_help($section){
 }
 
 function _femail_get_msg(){
-  $filename = fread(STDIN, 200);
-  $original_message = file_get_contents($filename);
+  $original_message = fread(STDIN, 10240);
   $msg = array(
     'body' => $original_message
   );
@@ -281,4 +280,4 @@ function femail_drush_callback(){
   // else we need to create a node, or creating a comment has failed as the 
   // msgid could not be found.
   _femail_post_forum_topic($msg, $user, $node_status);
-}
\ No newline at end of file
+}
diff --git a/femail_procmail_drush b/femail_procmail_drush
index c1f902c..6b0775a 100644
--- a/femail_procmail_drush
+++ b/femail_procmail_drush
@@ -4,12 +4,7 @@
 # path, and drushrc.php MUST be set up with the root directory of the Drupal
 # install.
 
-TMPFILE=`mktemp`
-# Why is the following step required?  Silly
-chmod 700 $TMPFILE
-# Populate the temp file
-cat <&0 > $TMPFILE
 # Find the domain name
-DOMAIN=`cat $TMPFILE | grep ^To | head -n1 | sed -r "s/.*@//;s/([a-zA-Z0-9\-\.]*).*/\1/"`
-# Execute Drush
-echo -n $TMPFILE | drush -l http://$DOMAIN femail
\ No newline at end of file
+DOMAIN=`cat <&0 | grep ^To | head -n1 | sed -r "s/.*@//;s/([a-zA-Z0-9\-\.]*).*/\1/"`
+# Execute Drush, passing the email message
+cat <&0 | drush -l http://$DOMAIN femail
-- 
1.7.8.3

