procmail
[Top] [All Lists]

RE: Alter Body Based on Looked-up Data

2007-05-30 13:12:49
Sokol, Ryan - 244 wrote Wednesday, May 30, 2007 9:25 PM:


I'm not looking to hire anyone.  I just want to know the following:

1.  Is my goal achievable/feasible?
2.  I know how to get the email address (via my php script).  
I've got this recipe working:

:0
| /usr/local/bin/php $HOME/getAndSend.php; \
  cat > /dev/null

But, as you can see, the email is basically terminated by 
procmail.  I have my php script actually recreating an email 
after parsing through the data.  I know this is not the best 
solution.  I'm looking for a way to let the email go through 
but after I get the data I need.  I think I can do this with 
a recipe like this:

:0
CUSTOM_DATA = | /usr/local/bin/php $HOME/getCustomBodyPrependData.php

You have certainly gone to a lot of programming effort to do
things that procmail and/or formail can do simply and that
have been documented and discussed inumerable times in these
lists.  I have to ask -- please do not take offense -- why
you're reinventing the wheel.  You ought, imho, to be reviewing
the basic procmail examples man page at the least, and reading
a couple of FAQs such as Nancy McGough's QuickStart pages.


        CLEANFROM = `formail -IReply-To: -rtzxTo:`

Will get your sender's address just fine -- it matters not
a whit whether he sent text or HTML or anything else.

Your above proposed recipe won't quite work because the
syntax is slightly off.  When using

  :0
  VAR=| piped_action

there cannot be spaces after VAR or between the equals sign
and the pipe.  (There can be space after the pipe, though.)

In any case, there is a known procmail bug such that that syntax
can corrupt memory at unpredictable addresses.  So if you don't
have a patch, you probably want to use the backtick sytnax
as in CLEANFROM above.

Another point is, if you would take five minutes and read
"man procmailrc" and "man procmailex", you will see that
your kludge of rewriting mail output from your script is
unnecessary and you could simply have used the c-flag
on the recipe.  This is what I mean by reinventing the
wheel.  I am sure the script took more time to write
than it would have just to peruse those two man pages
quickly.


Once I have this data (might be html) in the CUSTOM_DATA 
variable, all I need to do is prepend it to the body.  This 
is where it gets tricky and where I need you guys' help. 3.  
Is there a solid way to prepend the email body regardless of 
format and still preserve the email structure and components?

I would use a tool such as demime (web-search on that word) to
convert the mail to text.  But Bart and I discussed prepending
things in the body 2-3 days ago in some detail.

Dallman


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>