Re: [PHP] Piping Mime String to Metamail Fails -- Solution

2001-07-18 Thread Jeff Hill

Don Read wrote:
 
 On 13-Jul-01 Jeff Hill wrote:
  Don Read wrote:
  On 13-Jul-01 Jeff Hill wrote:
   Don Read wrote:
   On 13-Jul-01 Jeff Hill wrote:
I've tried everything I can to pipe a string with mime content to
metamail, but it fails in every variation of:

--snip---

 ok, i was thinking system(), but was on the fpassthru page in the manual ...
 sorry.
 But looking at your while (!feof()) loop above ...
 Hey, there are limits to a shell argument length, ya know.

Actually, I truly am ignorant of the limits, but hopefully I've avoided
any disastrous outcomes in my solution.

 alternative:
 $p=popen('/usr/bin/metamail -d -q -r -w -x -y','w');
 fwrite($p, $mime_string);
 pclose($p);
 

I tried your code above, and while it did process the mime, it didn't
return the results so that I could determine the file name. I did try
many different tacks, but nothing seemed to work -- that may of course
just be due to my limited knowledge.

After messing with this for several days, I found that metamail was a
poor choice anyway, reading that development has apparently stopped and
that it has a security hole in the current version. 

I then tried reformime, from the maildrop package. It worked better, but
I ran into the same problems trying to get it to work with PHP.

In the end, I opted to have my mail server (qmail) pipe incoming
messages to MHonArc (it does a wonderful job handling mime). MHonArc
extracts the mime and then passes the rest of the message to PHP, which
puts it into an MySQL database. This may not be an elegant solution, and
I suspect it's wasteful of resources, but my usage is only for our
internal customer support and contact management -- a hundred or so
e-mail a day.

While this took far longer than I ever expected, it is wonderful to be
able to match incoming mail against our user database (which is in
MySQL). Now a user's entire record, past e-mail, followups and the whole
thing pop-up whenever they send us a message.

Thanks for all the effort. 

Best Regards,

Jeff Hill


 Regards,
 --
 Don Read   [EMAIL PROTECTED]
 -- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.

-- 

--  HR On-Line:  The Network for Workplace Issues --
http://www.hronline.com - Ph:416-604-7251 - Fax:416-604-4708


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Piping Mime String to Metamail Fails

2001-07-13 Thread Don Read

`
On 13-Jul-01 Jeff Hill wrote:
 I've tried everything I can to pipe a string with mime content to
 metamail, but it fails in every variation of:
 
 exec(echo $mime_string | /usr/bin/metamail -d -q -r -w -x -y ,
 $met_res) ;
 

 what about /bin/echo ...

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Piping Mime String to Metamail Fails

2001-07-13 Thread Jeff Hill

Don Read wrote:
 On 13-Jul-01 Jeff Hill wrote:
  I've tried everything I can to pipe a string with mime content to
  metamail, but it fails in every variation of:
 
  exec(echo $mime_string | /usr/bin/metamail -d -q -r -w -x -y ,
  $met_res) ;
 
  what about /bin/echo ...

Nope, but I do appreciate the thought. Using /bin/echo just results in
$met_res becoming an empty array, as does my example string.

I should have said before that I've also tried this with several
versions of php, primarily 4.0.6 (all on Debian sid linux). 

Regards,

Jeff Hill
 
 Regards,
 --
 Don Read   [EMAIL PROTECTED]
 -- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 

--  HR On-Line:  The Network for Workplace Issues --
http://www.hronline.com - Ph:416-604-7251 - Fax:416-604-4708


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Piping Mime String to Metamail Fails

2001-07-13 Thread Don Read


On 13-Jul-01 Jeff Hill wrote:
 Don Read wrote:
 On 13-Jul-01 Jeff Hill wrote:
  I've tried everything I can to pipe a string with mime content to
  metamail, but it fails in every variation of:
 
  exec(echo $mime_string | /usr/bin/metamail -d -q -r -w -x -y ,
  $met_res) ;
 
  what about /bin/echo ...
 
 Nope, but I do appreciate the thought. Using /bin/echo just results in
 $met_res becoming an empty array, as does my example string.
 

Huh ?

$cmd='/bin/echo'  . $mime_string | /usr/bin/metamail -d -q -r -w -x -y ;
echo ' cmd is:br', $cmd, 'p';
fpassthru($cmd);

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Piping Mime String to Metamail Fails

2001-07-13 Thread Jeff Hill

Don Read wrote:
 On 13-Jul-01 Jeff Hill wrote:
  Don Read wrote:
  On 13-Jul-01 Jeff Hill wrote:
   I've tried everything I can to pipe a string with mime content to
   metamail, but it fails in every variation of:
  
   exec(echo $mime_string | /usr/bin/metamail -d -q -r -w -x -y ,
   $met_res) ;
 
   what about /bin/echo ...
 
  Nope, but I do appreciate the thought. Using /bin/echo just results in
  $met_res becoming an empty array, as does my example string.
 
 
 Huh ?

 
 $cmd='/bin/echo'  . $mime_string | /usr/bin/metamail -d -q -r -w -x -y ;
 echo ' cmd is:br', $cmd, 'p';
 fpassthru($cmd);


Well, I really do appreciate the help; maybe I'm misunderstanding
something. Using your statement above and executing the php script from
bash, I first get the results of your echo statement:

  cmd is:br/bin/echo 
  . . . then the $mime_string, and then on the last line, 
  | /usr/bin/metamail -d -q -r -w -x -y pbr

After your echo statement, the fpassthru($cmd) results come back: 

bWarning:/b Supplied argument is not a valid File-Handle resource in
b./mimescript_test.php/b on line b9/bbr

The entire contents of this mimescript_test.php are:
---
#!/usr/local/bin/php -q
?php
 
$fp0 = fopen('php://stdin','r') or die(couldnt open stdin); 
while(!feof($fp0)) {
$mime_string .= fgets($fp0,4096);
}
$cmd='/bin/echo'  . $mime_string | /usr/bin/metamail -d -q -r -w -x -y
;
echo ' cmd is:br', $cmd, 'p';
fpassthru($cmd);
?


As it seems fpassthru is supposed to work with the file pointer rather
than string, I did try using $fp0 rather than $mime_string, but I got
not a valid File-Handle resource.

If I substitute exec for fpassthru and add a $return to capture what
comes back, I get an empty array (I get a response of Array when
attempting to echo the $return variable, when I echo $return[0], etc., I
get nothing.

If I substitute system for fpassthru, I get only 127 when I echo the
$return.

I'm not the expert, but it certainly seems the problem lies in getting
the /bin/echo command pipe the string to metamail, and I'm not certain
how to make it do so.

Regards,

Jeff Hill

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Piping Mime String to Metamail Fails

2001-07-13 Thread Hank Marquardt

www.php.net/popen ? ... or am I missing something?

On Fri, Jul 13, 2001 at 07:52:51PM -0400, Jeff Hill wrote:
 Don Read wrote:
  On 13-Jul-01 Jeff Hill wrote:
   Don Read wrote:
   On 13-Jul-01 Jeff Hill wrote:
I've tried everything I can to pipe a string with mime content to
metamail, but it fails in every variation of:
   
exec(echo $mime_string | /usr/bin/metamail -d -q -r -w -x -y ,
$met_res) ;
  
what about /bin/echo ...
  
   Nope, but I do appreciate the thought. Using /bin/echo just results in
   $met_res becoming an empty array, as does my example string.
  
  
  Huh ?
 
  
  $cmd='/bin/echo'  . $mime_string | /usr/bin/metamail -d -q -r -w -x -y ;
  echo ' cmd is:br', $cmd, 'p';
  fpassthru($cmd);
 
 
 Well, I really do appreciate the help; maybe I'm misunderstanding
 something. Using your statement above and executing the php script from
 bash, I first get the results of your echo statement:
 
   cmd is:br/bin/echo 
   . . . then the $mime_string, and then on the last line, 
   | /usr/bin/metamail -d -q -r -w -x -y pbr
 
 After your echo statement, the fpassthru($cmd) results come back: 
 
 bWarning:/b Supplied argument is not a valid File-Handle resource in
 b./mimescript_test.php/b on line b9/bbr
 
 The entire contents of this mimescript_test.php are:
 ---
 #!/usr/local/bin/php -q
 ?php
  
 $fp0 = fopen('php://stdin','r') or die(couldnt open stdin); 
 while(!feof($fp0)) {
 $mime_string .= fgets($fp0,4096);
 }
 $cmd='/bin/echo'  . $mime_string | /usr/bin/metamail -d -q -r -w -x -y
 ;
 echo ' cmd is:br', $cmd, 'p';
 fpassthru($cmd);
 ?
 
 
 As it seems fpassthru is supposed to work with the file pointer rather
 than string, I did try using $fp0 rather than $mime_string, but I got
 not a valid File-Handle resource.
 
 If I substitute exec for fpassthru and add a $return to capture what
 comes back, I get an empty array (I get a response of Array when
 attempting to echo the $return variable, when I echo $return[0], etc., I
 get nothing.
 
 If I substitute system for fpassthru, I get only 127 when I echo the
 $return.
 
 I'm not the expert, but it certainly seems the problem lies in getting
 the /bin/echo command pipe the string to metamail, and I'm not certain
 how to make it do so.
 
 Regards,
 
 Jeff Hill
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
Hank Marquardt [EMAIL PROTECTED]
http://web.yerpso.net

Web  Database Development in PHP, MySQL/PostgreSQL
Small Office Networking Solutions - Debian GNU/Linux  FreeBSD
PHP Instructor - HTML Writers Guild http://www.hwg.org
*** PHP II The Cool Stuff starts July 16, 2001
*** http://www.hwg.org/services/classes/p181.1.html


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Piping Mime String to Metamail Fails

2001-07-13 Thread Don Read


On 13-Jul-01 Jeff Hill wrote:
 Don Read wrote:
 On 13-Jul-01 Jeff Hill wrote:
  Don Read wrote:
  On 13-Jul-01 Jeff Hill wrote:
   I've tried everything I can to pipe a string with mime content to
   metamail, but it fails in every variation of:
  
   exec(echo $mime_string | /usr/bin/metamail -d -q -r -w -x -y ,
   $met_res) ;
 
   what about /bin/echo ...
 
  Nope, but I do appreciate the thought. Using /bin/echo just results in
  $met_res becoming an empty array, as does my example string.
 
 
 Huh ?
 
  
 $cmd='/bin/echo'  . $mime_string | /usr/bin/metamail -d -q -r -w -x -y ;
 echo ' cmd is:br', $cmd, 'p';
 fpassthru($cmd);
 
 
 Well, I really do appreciate the help; maybe I'm misunderstanding
 something. Using your statement above and executing the php script from
 bash, I first get the results of your echo statement:
 
   cmd is:br/bin/echo 
   . . . then the $mime_string, and then on the last line, 
   | /usr/bin/metamail -d -q -r -w -x -y pbr
 
 After your echo statement, the fpassthru($cmd) results come back: 
 
 bWarning:/b Supplied argument is not a valid File-Handle resource in
 b./mimescript_test.php/b on line b9/bbr
 
 The entire contents of this mimescript_test.php are:
 ---
#!/usr/local/bin/php -q
 ?php
  
 $fp0 = fopen('php://stdin','r') or die(couldnt open stdin); 
 while(!feof($fp0)) {
 $mime_string .= fgets($fp0,4096);
 }
 $cmd='/bin/echo'  . $mime_string | /usr/bin/metamail -d -q -r -w -x -y
 ;
 echo ' cmd is:br', $cmd, 'p';
 fpassthru($cmd);
 ?
 
 
 As it seems fpassthru is supposed to work with the file pointer rather
 than string, I did try using $fp0 rather than $mime_string, but I got
 not a valid File-Handle resource.
 
 If I substitute exec for fpassthru and add a $return to capture what
 comes back, I get an empty array (I get a response of Array when
 attempting to echo the $return variable, when I echo $return[0], etc., I
 get nothing.
 
 If I substitute system for fpassthru, I get only 127 when I echo the
 $return.
 
 I'm not the expert, but it certainly seems the problem lies in getting
 the /bin/echo command pipe the string to metamail, and I'm not certain
 how to make it do so.
 

ok, i was thinking system(), but was on the fpassthru page in the manual ...
sorry.

But looking at your while (!feof()) loop above ... 
Hey, there are limits to a shell argument length, ya know.
   
alternative:
$p=popen('/usr/bin/metamail -d -q -r -w -x -y','w');
fwrite($p, $mime_string);
pclose($p);


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]