While Matt has graciously provided one possible approach to the problem
before S K Rana <rana(_at_)akr(_dot_)com>, I would like to point out two
problems
with it.
Matt Dunford <matt(_at_)stary(_dot_)zoomedia(_dot_)com> writes:
...
$lines = explode('\n', $header);
That's not right. rfc822 header fields may extend past a newline if
the preceeding line starts with a space or tab character. You should
either a) do the header extractions in procmail and then have php get
the values from the environment, b) use a different method of finding the
desired header fields in php that takes header continuations into account,
or c) feed the message through "formail -c" before piping it into php.
Those are in approximate order of CPU efficiency.
# iterate through header looking for certain
$wanted_headers = array( 'sender', 'date', 'time', 'subject' );
while ($line = array_shift($lines))
if (eregi('^$wanted_headers', $line))
$$wanted_headers = eregi_replace('^$wanted_headers: ', '', $line);
You left out the colon in the first regexp, which may cause problems if
the message contains a Date-Received: field, or something like that.
Be aware that what is allowed between the field name and the colon,
and it is not required after the colon. As a result, I suspect that
those last two lines would be more correct as:
if (eregi('^($wanted_headers)[ \t]*:', $line))
$$wanted_headers = eregi_replace('^($wanted_headers)[ \t]*: ?', '', $line);
However, that syntax is a guess, as I've never programmed in php before,
so it may be fundamentally wrong.
Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail