Monday, December 7, 2009

Remove message in email body with pine

email program, pine, has a function that you can filter your message before you send your message out.

Why I want to do it? Since I am idiot enough to include sensitive information in my email body time by time. And people keep warning me about that. Using pine is really cool but composing email too fast without carefully reviewing message content itself is not really cool.

So here is how you need to do to setup basic filter function:
1. first go to S->C-> and find "sending-filters"
2. give your script or program that will parse your message and does necessary replacement or remove.

ex: /path/to/your/program/ _TMPFILE_ _RESULTFILE_

detail option of command modifying tokens: can be found here:

And in my perl script I read two arguments in. First is _TMPFILE_ which is exactly your message body, and you can parse this in your program. Second is _RESULTFILE_ which is the message that you want to show after sending out.

Here is my example:
#!/usr/bin/perl -w

@patterns = ( 'Bad Words', 'Dirty Words' );

$text = $ARGV[0];
$result = $ARGV[1];

open( TEXT, "+<$text" ) or die $!; open( RESULT, ">$result") or die $!;;

// put all message into lines array.
@lines = ;
// move pointer to head of message
seek TEXT,0,0;

// step through message line by line
foreach $line (@lines)
// step through pattern by pattern and replace them to an empty string. (remove them)
foreach $onep ( @patterns )
$line =~ s/$onep//g;
print TEXT $line;

// show some message after change.
printf RESULT ("%s\n", "Done parsing");
close( TEXT );
close( RESULT );

Very neat right?

No comments:

Post a Comment