procmail
[Top] [All Lists]

Re: Can you help me? about sendmail and pipe!

1999-07-22 21:36:33
Sendmail pipes the entire message (headers and body)
to the STDIN.  You can read/parse a message like this:


---- cut here ---
#! /usr/bin/perl
#

$bodyflag = 0;

while ($line = <STDIN>) {
    $bodyflag = 1 if ($line eq "\n");
    if ($bodyflag) {
        ... parse the body ...
    }
    else {
        ... parse the header ...
    }
}
------------------

That skeleton program will read each line of the message,
store it in the variable $line.  You can detect body and
header by searching for the first line equal to a carriage
return "\n" only - that's where I set the variable $bodyflag
so you can separate parsing the header or body based on
your needs.

There are probably thousands of ways of doing this with PERL.
My suggestion may not be the best -- consult your local PERL
guru for more information.

I'll cc: this post to the procmail mailing list in case someone
there can help you more.

John

At 12:07 PM 7/23/99 +0800, mazhiqiang(_at_)126(_dot_)com wrote:
Dear Sir,

I want to get your help. Can you help me?

Question:

When sendmail use alias to pipe to a program,

What message do Sednmail has piped to the Program?

Header? Body?

If I write the program myself,  how can i get the items of  header,
how can i get the body?

I am sorry, I am newer to Sendmail, But I want to write a program about
sendmail.


Any suggestion will userful.

Thank you

Brown


<Prev in Thread] Current Thread [Next in Thread>
  • Re: Can you help me? about sendmail and pipe!, John Coy <=