procmail question regarding full line matching

procmail question regarding full line matching

am 28.02.2005 23:29:42 von Lucas Carey

Hi All,
I have mutt setup to Bcc me on all messages. I'd like to setup procmail to
save these messages into a file based on recipient. I have the following:

:0
*^From:.*lcarey@my.email.adr
* ^To:.*\/[^ ].*
/users/lcarey/mail/sent/$MATCH

This has lots of problems, such as saving messages as the first name when
email is in the form "first last" and not handling
multiple email addresses. I'd like to match the address part of evey
email in the To: header. Is something like this possible?
If there are multiple addresses, I'd like the message saved into multiple
places. Is this possible?
Is there a way to make the matching greedy, or force .* to match to the
end of the line?
If It is possible to do with a single address but not
multiple I could have a regex that tried to match multiple emails, and if
so send the email to a perl prog that I can write to do what I want. The
next recipie would then match single email messages.

-Lucas

Re: procmail question regarding full line matching

am 01.03.2005 01:49:22 von Alan Connor

On Mon, 28 Feb 2005 17:29:42 -0500, Lucas Carey
wrote:


> Hi All, I have mutt setup to Bcc me on all messages.

If you are wanting a copy with all headers in order to be
able to prove that you sent the mail, it is better to send
them to another mailbox on another server, or to another
(phantom) user on your own network.

And you are asking for trouble from trolls and mail loops by
accepting mail from yourself.

I'd at least have mutt add a unique header you could include
in the procmail recipe. (my_hdr)

> I'd like
> to setup procmail to save these messages into a file based on
> recipient. I have the following:
>
>:0 *^From:.*lcarey@my.email.adr
> * ^To:.*\/[^ ].*
> /users/lcarey/mail/sent/$MATCH
>

* ^To:.*\/[A-Za-z0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+

Better regex...

> This has lots of problems, such as saving messages as the first
> name when email is in the form "first last"
> and not handling multiple email addresses. I'd like to match
> the address part of evey email in the To: header. Is something
> like this possible? If there are multiple addresses, I'd like
> the message saved into multiple places. Is this possible? Is
> there a way to make the matching greedy, or force .* to match
> to the end of the line? If It is possible to do with a single
> address but not multiple I could have a regex that tried to
> match multiple emails, and if so send the email to a perl prog
> that I can write to do what I want. The next recipie would then
> match single email messages.
>
> -Lucas
>

Hmmmm.....How many addresses do you send to? Here's an
idea:

:0
* ^From:.*lcarey@my.email.adr
* ^X-UNIQUE: foo
{

REGEX="[A-Za-z0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+"

# does that need some "\" escapes?

:0
* ^To:.*\/"${REGEX}"
/users/lcarey/mail/sent/${MATCH}

:0 a
* ^To:.*"${REGEX}".*\/"${REGEX}"
/users/lcarey/mail/sent/${MATCH}

:0 a
* ^To:.*"${REGEX}".*"${REGEX}".*\/"${REGEX}"
/users/lcarey/mail/sent/${MATCH}

}


See how that works? If the first recipe is successful, the second
will look for another email address in the second position and if
it finds one, will send a copy of the mail to that mailbox.

For the third recipe, it is still referencing the first one (if
it was successful), and will check to see if there is an address
in the third position...

Gotta be a better way, though.....Piping them to a script is an
option, as you mention above, but a little tricky with maildir.

HTH


AC

Re: procmail question regarding full line matching

am 01.03.2005 16:35:15 von AK

Lucas Carey wrote:

> Hi All,
> I have mutt setup to Bcc me on all messages. I'd like to setup procmail to
> save these messages into a file based on recipient. I have the following:
>
> :0
> *^From:.*lcarey@my.email.adr
> * ^To:.*\/[^ ].*
> /users/lcarey/mail/sent/$MATCH
>
> This has lots of problems, such as saving messages as the first name when
> email is in the form "first last" and not handling
> multiple email addresses. I'd like to match the address part of evey
> email in the To: header. Is something like this possible?
> If there are multiple addresses, I'd like the message saved into multiple
> places. Is this possible?
> Is there a way to make the matching greedy, or force .* to match to the
> end of the line?
> If It is possible to do with a single address but not
> multiple I could have a regex that tried to match multiple emails, and if
> so send the email to a perl prog that I can write to do what I want. The
> next recipie would then match single email messages.
>
> -Lucas
>

Lucas,

mutt already has the ability to save outgoing messages based on the
username part of the first recipients address (Fcc).

if you want to just get the first email address, try
* ^To:.+\<\/([a-z0-9._-]+@([a-z0-9.-]+)+\.[a-z]+)



AK

Re: procmail question regarding full line matching

am 01.03.2005 21:19:13 von Lucas Carey

On Tue, 01 Mar 2005 10:35:15 -0500, AK wrote:
> Lucas Carey wrote:
>> Hi All,
>> I have mutt setup to Bcc me on all messages. I'd like to setup procmail to
>> save these messages into a file based on recipient. I have the following:
[cut]
> Lucas,
>
> mutt already has the ability to save outgoing messages based on the
> username part of the first recipients address (Fcc).
but I have to specify each email address that I want saved individually.
I don't want a new Fcc entry for each person I send an email.

Re: procmail question regarding full line matching

am 01.03.2005 22:49:03 von Alan Connor

On Mon, 28 Feb 2005 17:29:42 -0500, Lucas Carey
wrote:

> Hi All, I have mutt setup to Bcc me on all messages. I'd like
> to setup procmail to save these messages into a file based on
> recipient. I have the following:
>
>:0 *^From:.*lcarey@my.email.adr * ^To:.*\/[^ ].*
>/users/lcarey/mail/sent/$MATCH
>
> This has lots of problems, such as saving messages as the first
> name when email is in the form "first last"
> and not handling multiple email addresses. I'd like to match
> the address part of evey email in the To: header. Is something
> like this possible? If there are multiple addresses, I'd like
> the message saved into multiple places. Is this possible? Is
> there a way to make the matching greedy, or force .* to match
> to the end of the line? If It is possible to do with a single
> address but not multiple I could have a regex that tried to
> match multiple emails, and if so send the email to a perl prog
> that I can write to do what I want. The next recipie would then
> match single email messages.
>
> -Lucas
>

Got it! But since you don't even have the courtesy to respond to
people when they try to help you, YOU don't get it.

I have it in my calendar to post the solution in a couple of
months for the Archives.

AC

Re: procmail question regarding full line matching

am 02.03.2005 18:24:26 von AK

Lucas Carey wrote:
> On Tue, 01 Mar 2005 10:35:15 -0500, AK wrote:
>
>>Lucas Carey wrote:
>>
>>>Hi All,
>>>I have mutt setup to Bcc me on all messages. I'd like to setup procmail to
>>>save these messages into a file based on recipient. I have the following:
>
> [cut]
>
>>Lucas,
>>
>>mutt already has the ability to save outgoing messages based on the
>>username part of the first recipients address (Fcc).
>
> but I have to specify each email address that I want saved individually.
> I don't want a new Fcc entry for each person I send an email.
>
>

Lucas,

What exactly are you attempting to do?

Are you trying to save a copy of the same message based on to whom it
was sent?
i.e a message sent to joe, james, dina, and diane, you want saved in:
/users/lcarey/mail/sent/joe
/users/lcarey/mail/sent/james
/users/lcarey/mail/sent/dina
/users/lcarey/mail/sent/diane

To what end?

In short, I do not believe it can be done within procmail.
You could have a rule that will envoke a script and will perform the
duplication task.

you might be better suited to run your outgoing messages through a
filter whose task is to copy the message into your deignated mailboxes.

AK

Re: procmail question regarding full line matching

am 02.03.2005 21:22:48 von Alan Connor

On Wed, 02 Mar 2005 12:24:26 -0500, AK
wrote:



>
> In short, I do not believe it can be done within procmail.

Yes it can, by calling on some shell functionality:

$ Evaluate the remainder of this condition according to
sh(1) substitution rules inside double quotes, skip
leading whitespace, then reparse it.

Hint: VAR=| (formail -xTo:)



Like I said, I'll be posting the full solution in a couple of
months.

I am purely sick of these rude assholes who think that we are
some kind of scripting machine that they can turn on and off.

I now give such people a certain score and do not respond to
any subsequent questions they post.

And their juvenile header-munging does not fool my newsfilter
for a second.

AC

Re: procmail question regarding full line matching

am 03.03.2005 18:32:10 von Lucas Carey

On Wed, 02 Mar 2005 20:22:48 +0000, Alan Connor wrote:

> On Wed, 02 Mar 2005 12:24:26 -0500, AK
> wrote:
>
>
>
>>
>> In short, I do not believe it can be done within procmail.
>
> Yes it can, by calling on some shell functionality:
>
> $ Evaluate the remainder of this condition according to
> sh(1) substitution rules inside double quotes, skip
> leading whitespace, then reparse it.
>
> Hint: VAR=| (formail -xTo:)
>
>
>
> Like I said, I'll be posting the full solution in a couple of
> months.
>
> I am purely sick of these rude assholes who think that we are
> some kind of scripting machine that they can turn on and off.
>
> I now give such people a certain score and do not respond to
> any subsequent questions they post.
>
> And their juvenile header-munging does not fool my newsfilter
> for a second.
>
> AC
Actually, I spent an hour or two on wednesday trying to get your first
recipie (posted tuesday) working, with no luck. I figured I'd see if I
could get it working myself instead of posting another msg to the
newsgroup. I didn't have any luck. It has now been two entire days. Its
now thursday, and I'm replying to say that I couldn't get your recipie
working.
thank you for your help, and I'm sorry I wasn't able to reply in under
24hrs.
-Lucas

Re: procmail question regarding full line matching

am 03.03.2005 18:36:51 von Lucas Carey

On Wed, 02 Mar 2005 12:24:26 -0500, AK wrote:

> Lucas Carey wrote:
>> On Tue, 01 Mar 2005 10:35:15 -0500, AK wrote:
>>
>>>Lucas Carey wrote:
>>>
>>>>Hi All,
>>>>I have mutt setup to Bcc me on all messages. I'd like to setup procmail to
>>>>save these messages into a file based on recipient. I have the following:
>>
>> [cut]
>>
>>>Lucas,
>>>
>>>mutt already has the ability to save outgoing messages based on the
>>>username part of the first recipients address (Fcc).
>>
>> but I have to specify each email address that I want saved individually.
>> I don't want a new Fcc entry for each person I send an email.
>>
>>
>
> Lucas,
>
> What exactly are you attempting to do?
>
> Are you trying to save a copy of the same message based on to whom it
> was sent?
> i.e a message sent to joe, james, dina, and diane, you want saved in:
> /users/lcarey/mail/sent/joe
> /users/lcarey/mail/sent/james
> /users/lcarey/mail/sent/dina
> /users/lcarey/mail/sent/diane
>
> To what end?
[cut]
Exactly. Because this seems to make sense. Sometimes I'm not sure what
month (current saving method) I sent a message, but I know where it was in
the order-of-correspondance with someone, and I certainly know to whom I
sent it. I rarely find myself looking for a sent email where I know when I
sent it, but don't remember who I sent it to.
-Lucas

Re: procmail question regarding full line matching

am 03.03.2005 19:13:09 von NetworkElf

On Thu, 03 Mar 2005 12:32:10 -0500, Lucas Carey wrote:
> Actually, I spent an hour or two on wednesday trying to get your first
> recipie (posted tuesday) working, with no luck. I figured I'd see if I
> could get it working myself instead of posting another msg to the
> newsgroup. I didn't have any luck. It has now been two entire days. Its
> now thursday, and I'm replying to say that I couldn't get your recipie
> working.
> thank you for your help, and I'm sorry I wasn't able to reply in under
> 24hrs.
> -Lucas

Don't worry, his killfile entries only last 90 seconds or so. Sam has posted
a link which will explain the last posting you got. Google on this group and
Sam as the author. Look for replies to Beavis and you'll find it.

I'd post the link, but I'm not Sam today.

--
_________________________________________
NetworkElf: Super Genius, Computer Guy, Harley Owner!
Blindly serving the covert purposes of the
criminal-minded maniac behind Spews since 2003.

Re: procmail question regarding full line matching

am 03.03.2005 19:52:37 von Alan Connor

On Thu, 03 Mar 2005 12:32:10 -0500, Lucas Carey
wrote:

> On Wed, 02 Mar 2005 20:22:48 +0000, Alan Connor wrote:
>
>> On Wed, 02 Mar 2005 12:24:26 -0500, AK
>> wrote:
>>
>>
>>
>>
>>> In short, I do not believe it can be done within procmail.
>>
>> Yes it can, by calling on some shell functionality:
>>
>> $ Evaluate the remainder of this condition according to
>> sh(1) substitution rules inside double quotes, skip leading
>> whitespace, then reparse it.
>>
>> Hint: VAR=| (formail -xTo:)
>>
>>
>>
>> Like I said, I'll be posting the full solution in a couple of
>> months.
>>
>> I am purely sick of these rude assholes who think that we are
>> some kind of scripting machine that they can turn on and off.
>>
>> I now give such people a certain score and do not respond to
>> any subsequent questions they post.
>>
>> And their juvenile header-munging does not fool my newsfilter
>> for a second.
>>
>> AC
>
> Actually, I spent an hour or two on wednesday trying to get
> your first recipie (posted tuesday) working, with no luck. I
> figured I'd see if I could get it working myself instead
> of posting another msg to the newsgroup. I didn't have any
> luck. It has now been two entire days. Its now thursday, and
> I'm replying to say that I couldn't get your recipie working.
> thank you for your help, and I'm sorry I wasn't able to reply
> in under 24hrs. -Lucas


That's not the point.

I obviously hadn't tested it but was TRYING to help you.

You responded to AK didn't say anything to me.

Nor do I even believe the above: If you were trying to get it
work for that long you would have posted the fact that it
wasn't working and asked for further assistance.

The basic concept is sound. I've been using procmail and egrep
for a very long time. It's not even a complex recipe chain.

It's one that you would have come up with yourself if you
weren't too lazy and venal to even bother reading the
procmail manpages.

Assholes will never admit that they have done something wrong.
It's part of the job description.


AC

Re: procmail question regarding full line matching

am 03.03.2005 20:26:55 von Lucas Carey

On Thu, 03 Mar 2005 18:52:37 +0000, Alan Connor wrote:

> On Thu, 03 Mar 2005 12:32:10 -0500, Lucas Carey
> wrote:
>> Actually, I spent an hour or two on wednesday trying to get
>> your first recipie (posted tuesday) working, with no luck. I
>> figured I'd see if I could get it working myself instead
>> of posting another msg to the newsgroup. I didn't have any
>> luck. It has now been two entire days. Its now thursday, and
>> I'm replying to say that I couldn't get your recipie working.
>> thank you for your help, and I'm sorry I wasn't able to reply
>> in under 24hrs. -Lucas
>
>
> That's not the point.
>
> I obviously hadn't tested it but was TRYING to help you.
>
> You responded to AK didn't say anything to me.
>
> Nor do I even believe the above: If you were trying to get it
> work for that long you would have posted the fact that it
> wasn't working and asked for further assistance.
>
> The basic concept is sound. I've been using procmail and egrep
> for a very long time. It's not even a complex recipe chain.
>
> It's one that you would have come up with yourself if you
> weren't too lazy and venal to even bother reading the
> procmail manpages.
>
> Assholes will never admit that they have done something wrong.
> It's part of the job description.
>
>
> AC
You can believe what you'd like. If you got it working, and care to post,
then do so. If not, I'll do this in perl, where I am used to the regex
machinery.
I responded to AK because that was a response that I could write
immediatly upon reading his post.
-Lucas

Re: procmail question regarding full line matching

am 03.03.2005 20:50:21 von NetworkElf

On Thu, 03 Mar 2005 18:52:37 GMT, Alan Connor wrote:
>
> Assholes will never admit that they have done something wrong.
> It's part of the job description.

Mirror, mirror on the wall, who's the biggest one of all?

--
_________________________________________
NetworkElf: Super Genius, Computer Guy, Harley Owner!
Blindly serving the covert purposes of the
criminal-minded maniac behind Spews since 2003.

Re: procmail question regarding full line matching

am 03.03.2005 22:38:52 von Alan Connor

On Thu, 03 Mar 2005 14:26:55 -0500, Lucas Carey wrote:
>
>
> On Thu, 03 Mar 2005 18:52:37 +0000, Alan Connor wrote:
>
>> On Thu, 03 Mar 2005 12:32:10 -0500, Lucas Carey
>> wrote:
>>> Actually, I spent an hour or two on wednesday trying to get
>>> your first recipie (posted tuesday) working, with no luck. I
>>> figured I'd see if I could get it working myself instead
>>> of posting another msg to the newsgroup. I didn't have any
>>> luck. It has now been two entire days. Its now thursday, and
>>> I'm replying to say that I couldn't get your recipie working.
>>> thank you for your help, and I'm sorry I wasn't able to reply
>>> in under 24hrs. -Lucas
>>
>>
>> That's not the point.
>>
>> I obviously hadn't tested it but was TRYING to help you.
>>
>> You responded to AK didn't say anything to me.
>>
>> Nor do I even believe the above: If you were trying to get it
>> work for that long you would have posted the fact that it
>> wasn't working and asked for further assistance.
>>
>> The basic concept is sound. I've been using procmail and egrep
>> for a very long time. It's not even a complex recipe chain.
>>
>> It's one that you would have come up with yourself if you
>> weren't too lazy and venal to even bother reading the
>> procmail manpages.
>>
>> Assholes will never admit that they have done something wrong.
>> It's part of the job description.
>>
>>
>> AC
> You can believe what you'd like. If you got it working, and care to post,
> then do so. If not, I'll do this in perl, where I am used to the regex
> machinery.
> I responded to AK because that was a response that I could write
> immediatly upon reading his post.
> -Lucas

Okay. Perhaps I have become jaded by the trolls, etc. here on
the Usenet.

[Like that "networkelf" moron, who is really "Sam". (I just
see the name, not the subject, nor any optional headers, nor
the body of the post, which are stripped away before getting
to my newsreader, thanks to my newsfilter, which happens to be
procmail.)]

Where I bog down here is the maildir format. I just don't know
it at all. (I really _should_ get a handle on it.)

And I admit, after messing with it, that my original concept was
fatally flawed. Sorry, Lucas. My other solution is an mbox one.

Your best bet is probably to pipe the mails to a script, shell
or perl, and thence to your $MAILDIR.

If you pipe the mail, firstly, through "formail -xTo", the
addresses can be captured in a variable ($var, here). If you are
using a shell script, then "IFS=','" and "set $var" will give you
the addresses as $1, $2, etc. I'm sure that perl has the same
basic functionality.

Good luck.

AC

Re: procmail question regarding full line matching

am 03.03.2005 22:54:54 von NetworkElf

On Thu, 03 Mar 2005 21:38:52 GMT, Alan Connor wrote:
>
> [Like that "networkelf" moron, who is really "Sam". (I just
> see the name, not the subject, nor any optional headers, nor
> the body of the post, which are stripped away before getting
> to my newsreader, thanks to my newsfilter, which happens to be
> procmail.)]

WOO HOO!!! IMA SOCK!!!! IMA SAM SOCK!!!!!!

I knew, given time, persistence and a nominal display of intelligence would
cause Alan er... sorry... Mrs. Xena Bigfoot... to not read my messages and
declare me Sam.

By the way, Alan, as you don't read this, please note that it's NetworkElf.
Learn to spell.

--
_________________________________________
NetworkElf: Super Genius, Computer Guy, Harley Owner!
Blindly serving the covert purposes of the
criminal-minded maniac behind Spews since 2003.

Re: procmail question regarding full line matching

am 04.03.2005 00:00:22 von Alan Connor

On Thu, 03 Mar 2005 14:26:55 -0500, Lucas Carey wrote:
>
>
> On Thu, 03 Mar 2005 18:52:37 +0000, Alan Connor wrote:



This seems to work, Lucas:

:0
* ^From:.*you@your.isp
* ^Unique: yes
{

:0 c
* ^To.*\/[A-Za-z0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+
$MATCH


:0 c
* ^To.*[A-Za-z0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+.*\/[A-Z a-z
0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+
$MATCH

# etc.


}

AC

Re: procmail question regarding full line matching

am 04.03.2005 00:33:33 von Sam

This is a MIME GnuPG-signed message. If you see this text, it means that
your E-mail or Usenet software does not support MIME signed messages.

--=_mimegpg-commodore.email-scan.com-16615-1109892813-0005
Content-Type: text/plain; format=flowed; charset="US-ASCII"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Beavis writes:

> Assholes will never admit that they have done something wrong.
> It's part of the job description.

Right, asshole.



--=_mimegpg-commodore.email-scan.com-16615-1109892813-0005
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQBCJ57Nx9p3GYHlUOIRAi3EAJkBX5t8myKOOe2lFPLfsy3AgmlqOwCe P15K
BIzvqv0o/1PHPJ6U+3BYKZA=
=MW/H
-----END PGP SIGNATURE-----

--=_mimegpg-commodore.email-scan.com-16615-1109892813-0005--

Re: procmail question regarding full line matching

am 04.03.2005 11:16:14 von Alan Connor

On Thu, 03 Mar 2005 23:00:22 GMT, Alan Connor wrote:
>
>
> On Thu, 03 Mar 2005 14:26:55 -0500, Lucas Carey wrote:
>>
>>
>> On Thu, 03 Mar 2005 18:52:37 +0000, Alan Connor wrote:
>
>
>
> This seems to work, Lucas:
>
>:0
> * ^From:.*you@your.isp
> * ^Unique: yes
> {
>
>:0 c
> * ^To.*\/[A-Za-z0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+
> $MATCH
>
>
>:0 c
> * ^To.*[A-Za-z0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+.*\/[A-Z a-z
> 0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+
> $MATCH
>
> # etc.
>
>
> }
>
> AC
>

Jeeesh! I re-read your original post and wrote out some To
headers that matched your description:

{firstname/initialwithperiod space
maybemiddlename/maybeinitialwithperiod space lastname space
OR justtheemailaddress} comma space
maybeoneformatortheother...

Haven't been able to do it. About ready to pull my hair out!

But with the right regexes, the above _will_ work fine.

However, it would be simpler to filter the To line first:

:0 f
| simplifier.sh

Get it down to:

To: justaddress, justaddress, justaddress

This would be easier than doing it all with a script. Let
procmail do as much of the work as possible.

AC

Re: procmail question regarding full line matching

am 04.03.2005 14:24:27 von Lucas Carey

On Thu, 03 Mar 2005 23:00:22 +0000, Alan Connor wrote:

>> On Thu, 03 Mar 2005 18:52:37 +0000, Alan Connor wrote:
> This seems to work, Lucas:
>
> :0
> * ^From:.*you@your.isp
> * ^Unique: yes
> {
>
> :0 c
> * ^To.*\/[A-Za-z0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+
> $MATCH
>
>
> :0 c
> * ^To.*[A-Za-z0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+.*\/[A-Z a-z
> 0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+
> $MATCH
>
> # etc.
>
>
> }
>
> AC
Thanks Alan,
This seems to work in the couple of cases I threw at it:
email
name
email, email
name , email
One thing: for the recipie that detects N recipients, any recipe with <
N-1 will leave a copy of the message in my mail folder. I figure a final
regex that matches everything and directs to /dev/null should solve this,
but I was wondering if there was an official way to do this?
This weekend I'll play with it some more.
Reading your most recent post, you're suggesting that mung the To: field
just down to 'email, email, email', then just print back out the file to
stdout, where procmail will continue to process it?

thanks
-Lucas

Re: procmail question regarding full line matching

am 05.03.2005 00:29:19 von Alan Connor

On Fri, 04 Mar 2005 08:24:27 -0500, Lucas Carey
wrote:



> Thanks Alan, This seems to work in the couple of
> cases I threw at it: email name email, email
> name , email One thing: for the recipie that
> detects N recipients, any recipe with < N-1 will
> leave a copy of the message in my mail folder. I
> figure a final regex that matches everything and
> directs to /dev/null should solve this, but I was
> wondering if there was an official way to do this?
> This weekend I'll play with it some more. Reading
> your most recent post, you're suggesting that mung
> the To: field just down to 'email, email, email',
> then just print back out the file to stdout, where
> procmail will continue to process it?
>

Yeh. The ":0 f" recipe will send each mail to a filter script
and then return it to procmail for further processing:

:0
* ^From.*you@your.isp
* ^X-Bcc: Lucas
{
:0 f
| yourscript.sh

# With the To: header now simplified by the script, this
# will work perfectly:

:0 c
* ^To: \/[A-Za-z0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+
$MATCH


:0 c
* ^To: [A-Za-z0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+, \/[A-Za-z
0-9_.+-]+@[A-Za-z0-9_.+-]+\.[A-Za-z0-9]+
$MATCH

etc....

# A simpler regex would work, actually, more like the one you
# originally posted.

}

Really, the tool to use for the filter script is awk, and I'm
not very good with it.

comp.lang.awk
comp.unix.shell

You can extract the contents of the To: header with

var=`formail -xTo:`

Here's a somewhat crude and only partially tested filter script
in bash:

#!/bin/bash

# first, get rid of the old tempfile (see below)

rm /home/you/tempfileAAvvxx

# extract the contents of the To: header into a variable.

var=$(formail -xTo:)

# give each WORD (see man bash) a positional parameter ($1,$2,
etc)

set - $var

# check each WORD (man bash) to see if it has an email address
# in it, using shell wildcards (NOT regexes) and if it does,
# clean it up with sed and send it to a tempfile with no newlines
# (echo -n) with each address followed by a comma and a space

for pp in "$@"
do
case "$pp" in

*@*.* ) echo -n "$pp" | sed -e 's///' -e 's/,//' -e '
s/$/, /' >> /home/you/tempfileAAvvxx ;;
* ) ;;

esac

done

# put the contents of the tempfile in a variable

newto=$(cat /home/you/tempfileAAvvxx)

# have formail replace the old To: header with the
# contents of that tempfile

formail -I"To: ${newto}"


AC

Re: procmail question regarding full line matching

am 05.03.2005 01:17:32 von Alan Connor

On Fri, 04 Mar 2005 23:29:19 GMT, Alan Connor wrote:



>
> newto=$(cat /home/you/tempfileAAvvxx)
>

# To remove the final ", " and add a newline -- not sure
# whether this is necessary or not, Lucas.

newto=$(echo $(< /home/you/temfileAAvvxx) | sed 's/, $//')

# "< file" is faster than "cat file"


AC

Re: procmail question regarding full line matching

am 10.03.2005 21:26:54 von AK

Lucas Carey wrote:
> On Wed, 02 Mar 2005 12:24:26 -0500, AK wrote:
>
>
>>Lucas Carey wrote:
>>
>>>On Tue, 01 Mar 2005 10:35:15 -0500, AK wrote:
>>>
>>>
>>>>Lucas Carey wrote:
>>>>
>>>>
>>>>>Hi All,
>>>>>I have mutt setup to Bcc me on all messages. I'd like to setup procmail to
>>>>>save these messages into a file based on recipient. I have the following:
>>>
>>>[cut]
>>>
>>>
>>>>Lucas,
>>>>
>>>>mutt already has the ability to save outgoing messages based on the
>>>>username part of the first recipients address (Fcc).
>>>
>>>but I have to specify each email address that I want saved individually.
>>>I don't want a new Fcc entry for each person I send an email.
>>>
>>>
>>
>>Lucas,
>>
>>What exactly are you attempting to do?
>>
>>Are you trying to save a copy of the same message based on to whom it
>>was sent?
>>i.e a message sent to joe, james, dina, and diane, you want saved in:
>>/users/lcarey/mail/sent/joe
>>/users/lcarey/mail/sent/james
>>/users/lcarey/mail/sent/dina
>>/users/lcarey/mail/sent/diane
>>
>>To what end?
>
> [cut]
> Exactly. Because this seems to make sense. Sometimes I'm not sure what
> month (current saving method) I sent a message, but I know where it was in
> the order-of-correspondance with someone, and I certainly know to whom I
> sent it. I rarely find myself looking for a sent email where I know when I
> sent it, but don't remember who I sent it to.
> -Lucas

Lucas,

In this case, you might be better of logging the mailing in a flat file
or a bdb flatfile database.
i.e. when the message arrives, you can use the To, CC, Date and Subject
fields.

This might be more efficient for searches as well as space utilization.


AK