Page 1 of 1

how can I detect multi recipients using regular expressions?

Posted: Fri Sep 03, 2004 12:26 am
by quosego
In addition to my reply in the topic about multi-hops i repost here:

On my main account i get an increasing amount of spam. Although K9 works pretty accurate i need a second indicator before deleting automatically.

Since my adres is probably on several list i receive mails adressed to multiple recipients that are identical during a couple of days. By making a rule that detect both the K9 mark AND one other recipient adres (not mine offcourse) i manage to delete a lot of spam.
Unfortunately the adresses of the other recipients change from time to time so i have to add more rules.

So assuming i have adres me@myprovider.com i would need a rule that would look like:

IF
SUBJECT contains [spam] {= the K9 mark}
AND
TO contains anyotheradres@myprovider.com
THEN delete message


So the trick would be to detect if besides my own adres any other adres from the same provider is present in the TO field.

Posted: Fri Sep 03, 2004 1:55 am
by KY Dave
This isn't REG EXPR, but how about this setup?

2 RULES

1st Rule
IF
SUBJECT contains [spam] {= the K9 mark}
AND
TO contains me@myprovider.com
THEN PROTECT message

2nd Rule
IF
SUBJECT contains [spam] {= the K9 mark}
AND
TO WILDCARD *@myprovider.com
THEN DELETE message

If I remembe right, it has been stated that PROTECT won't allow an automatic deletion to happen, so I would think your emails would be safe.
Of course some tests would be required.

Posted: Fri Sep 03, 2004 2:08 am
by Rdsok
quosego,

I had hoped you figured out my quick response in the other post but that is how it goes. I think you could probably grasp this if I didn't say this the long way, but for the others out there I'll try to do a step by step for creating a rule with multiple criteria in PopTray v3.1 beta 6. (This won't work and isn't possible in the current released version of 3.03).

1. Goto the Rules Tab.

2. Click on the Add Rule button.

3. Name the Rule. (Whatever you will understand, it doesn't matter.)

4. Select from the drop down menu what account the Rule is good for. (All Accounts or One Selected Account)

5. On the Needed area select ALL Rows (this will make the rule only fire if both criteria match)

6. Create the two criteria you want to look for (see below using your examples)

[SUBJECT] --> [CONTAINS] --> [spam]

7. Now click the ADD ROW button to make a second criteria line.

[TO] --> [CONTAINS] --> anyotheradres@myprovider.com

8. Select the actions you want, in your example it would be DELETE FROM SERVER

9. Click the SAVE RULES button at the bottom of the page.

That should be all for the example you gave anyway.

quosego, If you can't understand something there just ask me to rephrase or explain my instructions where you don't understand.

:idea: Hey if you want, I'll come set it up for you... I sure could use a vacation :D . Of course the down side of that for you would be you'd have to send me the plane ticket.

Re: how can I detect multi recipients using regular expressions?

Posted: Fri Sep 03, 2004 3:57 am
by Rdsok
quosego wrote:So the trick would be to detect if besides my own adres any other adres from the same provider is present in the TO field.
quosego,

I completely missed reading this part of your post. Apparently KY Dave and I were both replying at the same time. His reply is more correct than mine ( I was assuming that you were going to look for a specific email address, not just an address that wasn't yours), but using a wildcard as he suggested will also match with your email address so that won't work well either.

I will try to think of a way that you can exclude your email account from the criteria using RegExpr but I may have to wait until I've had more sleep. I ended up having to start reloading my computer last night and only got about 2-3 hours of sleep and I'm starting to make errors apparently. :cry:

I can say this for certain, this will require 2 different rules with at least 2 criteria. One will need to look at the TO: field and one for the CC: field.

I'll reply back as soon as I can think of something.

Posted: Fri Sep 03, 2004 6:17 pm
by quosego
thanks dave and rdsok for responding and trying to help.

I guess dave his solution does not work because when my own mailadres is detected in the to field the email is protected regardles of the presence of other mailadresses (from the same provider).

Posted: Fri Sep 03, 2004 7:35 pm
by sandy&cloud
I think this regular expression will be helpful for you.

if your mail-address is "me@myprovider.com":

[^e]@myprovider\.com

apply it to 2 rows, "To:" and "CC:" and "mark as spam". also check "Account=me@myprovider.com" and "Needed=ANY".

this rule detects another person's name that contains "@myprovider.com" from "To:" and "CC:" field.
if there's only contains "me@myprovider.com" or another domain's mail-address ("me@xxx.com") will NOT match.

Posted: Fri Sep 03, 2004 8:04 pm
by KY Dave
quosego wrote:thanks dave and rdsok for responding and trying to help.

I guess dave his solution does not work because when my own mailadres is detected in the to field the email is protected regardles of the presence of other mailadresses (from the same provider).
Yep, I reread your post and contacted rdsok last evening and told him I didn't think either one of us had helped. Sorry :oops:

I hope the previous posting will fix you up. :)

Posted: Fri Sep 03, 2004 9:06 pm
by quosego
It sure did dave !


Thanks sandy&cloud, this is exactly what i was looking for.
Very interesting these reg exp:)

A better way (NOT)

Posted: Fri Jan 14, 2005 4:13 pm
by lemming
Whoops, I goofed. The regex I provided would not work either. Please ignore this posting. I'm working on a proper solution. - Lemming.


:oops: :oops: :oops:

UPDATE: See below for kludge.

A kludge

Posted: Sat Jan 15, 2005 4:46 pm
by lemming
Okay, I've come up with a kludge to detect multi recipients using regular expressions. I'm using a rule with two rows, both containing regex. If, for example, your address is mymail@myisp.com

Row 1

To | Reg Expr | mymail@myisp\.com.+myisp\.com

Row 2

To | Reg Expr | myisp\.com.+mymail@myisp\.com

You'll need to change the row options to "ANY Row"

Row 1 will match a header like:

To: mymail@myisp.com, fakeaddr1@otherisp.com, fakeaddr2@myisp.com

It just looks for your address, then followed by any other mention of your domain.

Row 2 is just a variant of Row 1 to catch headers like:

To: fakeaddr1@myisp.com, fakeaddr2@myisp.com, mymail@myisp.com

The first regex would not work if your address is last on the list. Row 2 fixes that.

However, there is one instance when this rule will catch valid e-mails - when the to: header has a duplicate of your address, e.g.

To: mymail@myisp.com, mymail@myisp.com, validemail@addy.com, myfriend@hisisp.com

This can happen if the sender accidentally clicks on your address twice. This is rare, and spammers never do this, but your friends and relatives might. :(

Like I said, this is a kludge. Don't use it to delete mail yet. Mark them as spam and make sure you log the rule. If I come up with a better rule, I'll post it.

Note: I've changed the color of all the @ symbols to prevent the forum software from turning any valid-looking address into a clickable link. Another kludge for the day ;)