[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - Script to Block Multiple Recipients to same domain

Script to Block Multiple Recipients to same domain

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Script to Block Multiple Recipients to same domain

Postby muncher1 » Mon Dec 20, 2004 12:18 pm

This is how most of my spam is sent.

1. Checking the header I'm in alphabetical order of a group of recipients sent to the same domain.

example:

jake@somewhere.com
jay@somewhere.com
joe@somewhere.com
john@somewhere.com
and so on.

I'd like to have a script run that does one or two things.

1. Check if my address is part of a multiple header like example above and move to junk mailbox, or
2. If I'm part of multiple recipients and none of the other recipients are in my address book then move to junk mailbox.

It would be nice to be able to adjust the count of recipients. In other words if I'm just one of three recipients I might give that a look see, but if I'm part of say 5 or 10 recipients and none of the recipients are in my address book then put to junk mailbox.

If this works well then I'd like to change it to don't even download just delete from server.

Any help would be appreciated.

Thx,

Chris
muncher1
Poco Tourist
 
Posts: 27
Joined: Sun Dec 19, 2004 2:23 pm

Postby Sandy » Mon Dec 20, 2004 2:49 pm

Here's one I wrote to do just that.

I can't recommend you use it since it has not been "user-fied" and it works only on my configuration. But it might give you some ideas. (Note I have clobbered the real addresses to protect the innocent :) )

Code: Select all
{  This script counts the number of times the string "xxxxx.com" appears
{  on the TO: and CC: lines; if there are more than #MaxNumber present
{  or the TO: or CC: lines contains one the special addresses found in the
{  CheckOtherAddresses subroutine, then the message is considered junkmail
{  it is moved to the $JunkMailbox folder
{
{  Author: Sandy (based on script by Slaven)
{  Written: 11/16/03
{  Modified:
{      11/1/04 - added subroutine to look for specific addresses
{
{  Notes:
{      Line numbers are zero based in PocoScript

  { ============ Process To fields =============== }

{set up variables
Set #NumberFound 0
Set #SpecialAddressFound 0
Set #MaxNumber 2
set $JunkMailbox "Junk Mail.mbx"

{loop thru TO: line counting occurences of "xxxxx.com"
ReadTo $list %message
LineCount #n $list
Set #i 0

:LoopTo
If #i = #n then ProcessCC
GetLine $address #i $list
Trim $address
Set $email $address
Lowercase $email
{look for special addresses; if not found, continue to count
Call CheckOtherAddresses
StringPos #z "xxxxx.com" $email
If #z = 0 Then FinishedA1
Inc #NumberFound

:FinishedA1
Inc #i
Goto LoopTo

  { ============ Now process CC fields =============== }

{loop thru CC: line counting occurences of "xxxxx.com"
:ProcessCC
ReadCC $list %message
LineCount #n $list
Set #i 0

:LoopCC
If #i = #n then Finished
GetLine $address #i $list
Trim $address
Set $email $address
Lowercase $email                     
{look for special addresses; if not found, continue to count
Call CheckOtherAddresses
StringPos #z "xxxxx.com" $email
If #z = 0 Then FinishedA2
Inc #NumberFound

:FinishedA2
Inc #i
Goto LoopCC

  { =============== Finish processing ================}

{if there are more occurences than #MaxNumber, consider msg to be spam
:Finished
{add 1 to #MaxNumber so that if stat below is the equivalent of <=
Inc #MaxNumber
If #SpecialAddressFound = 1 Then AddsgmHeader
If #NumberFound < #MaxNumber then ExitNow
:AddsgmHeader
AddHeader %message "X-sgm: " "sgmSpamMultiplexxxxx reject"
AppendToFile true
SaveMessage  %message $junkmailbox
DeleteMessage %message
Goto ExitNow

   { ============ Subroutines =======================}
{looks for specific addresses I have noticed only exist in spam
:CheckOtherAddresses
StringPos #y "sccready@xxxxx.com" $email
{if found, then msg is spam, so don't return to calling routine, just process as spam now
If #y = 0 Then ReturnNow
Inc #SpecialAddressFound
Goto Finished
:ReturnNow
Return

:ExitNow
Sandy
 

Thanks Sandy!

Postby muncher1 » Mon Dec 20, 2004 3:00 pm

I think I understand most of what it is doing. I'll modify it tomorrow and see if I can get it to work. Been a real productive day in the fight against spam. So far the new filter is still running 100% on accuracy.

This is a big favor. If its possible could you fill back in the areas you modified, of course using bogus data so I can tell what's part of the code and what's not.

I'm not the sharpest tool in the shed when it comes to programming. I almost need color codeing to follow the lines.

I'll let you know what I get done.

Thx again,
Chris
muncher1
Poco Tourist
 
Posts: 27
Joined: Sun Dec 19, 2004 2:23 pm

Postby Sandy » Mon Dec 20, 2004 3:12 pm

I didn't change that much. I just replaced my real address with "xxxxx". Put your ISP in there and you should have whole code.

For example, assuming your email address contains "earthlink":

Where it says:

StringPos #z "xxxxx.com" $email

just use:

StringPos #z "earthlink.com" $email

Now, my code depends on the ISP not being very common since then I might well get valid email with 3,4,5 or more "earthlink.com" addressses in it.
Sandy
 

Modified the Script!

Postby muncher1 » Mon Dec 20, 2004 4:26 pm

Sandy,

Do you think this will work?

Only changes is inputing "austin.rr.com" where I though it was suppose to go and a little script to set the MAX number as an input. I checked the debug and what ever number I put in on the "Setup Script" shows and is increased by one farther down the code. Here's what it looks like:

{ This script counts the number of times the string "austin.rr.com" appears
{ on the TO: and CC: lines; if there are more than #MaxNumber present
{ or the TO: or CC: lines contains one the special addresses found in the
{ CheckOtherAddresses subroutine, then the message is considered junkmail
{ it is moved to the $JunkMailbox folder
{
{ Author: Sandy (based on script by Slaven)
{ Written: 11/16/03
{ Modified:
{ 11/1/04 - added subroutine to look for specific addresses
{
{ Notes:
{ Line numbers are zero based in PocoScript
{
{ Modified 12/20/04:
{ Maximum Road Runner Recipients in Header found
{ If more then user input take to junk mailbox
{
{ ============ Process To fields =============== }

{ Define options in "Setup Script"
External $userdata1 "Total Max Road Runner Recipients" "8"

{
{set up variables
Set #NumberFound 0
Set #SpecialAddressFound 0
Set #MaxNumber $userdata1
set $JunkMailbox "Junk Mail.mbx"

{loop thru TO: line counting occurences of "austin.rr.com"
ReadTo $list %message
LineCount #n $list
Set #i 0

:LoopTo
If #i = #n then ProcessCC
GetLine $address #i $list
Trim $address
Set $email $address
Lowercase $email
{look for special addresses; if not found, continue to count
Call CheckOtherAddresses
StringPos #z "austin.rr.com" $email
If #z = 0 Then FinishedA1
Inc #NumberFound

:FinishedA1
Inc #i
Goto LoopTo

{ ============ Now process CC fields =============== }

{loop thru CC: line counting occurences of "austin.rr.com"
:ProcessCC
ReadCC $list %message
LineCount #n $list
Set #i 0

:LoopCC
If #i = #n then Finished
GetLine $address #i $list
Trim $address
Set $email $address
Lowercase $email
{look for special addresses; if not found, continue to count
Call CheckOtherAddresses
StringPos #z "austin.rr.com" $email
If #z = 0 Then FinishedA2
Inc #NumberFound

:FinishedA2
Inc #i
Goto LoopCC

{ =============== Finish processing ================}

{if there are more occurences than #MaxNumber, consider msg to be spam
:Finished
{add 1 to #MaxNumber so that if stat below is the equivalent of <=
Inc #MaxNumber
If #SpecialAddressFound = 1 Then AddsgmHeader
If #NumberFound < #MaxNumber then ExitNow
:AddsgmHeader
AddHeader %message "X-sgm: " "sgmSpamMultiplexxxxx reject"
AppendToFile true
SaveMessage %message $junkmailbox
DeleteMessage %message
Goto ExitNow

{ ============ Subroutines =======================}
{looks for specific addresses I have noticed only exist in spam
:CheckOtherAddresses
StringPos #y "sccready@xxxxx.com" $email
{if found, then msg is spam, so don't return to calling routine, just process as spam now
If #y = 0 Then ReturnNow
Inc #SpecialAddressFound
Goto Finished
:ReturnNow
Return

:ExitNow
Last edited by muncher1 on Sat Jan 15, 2005 2:16 pm, edited 1 time in total.
muncher1
Poco Tourist
 
Posts: 27
Joined: Sun Dec 19, 2004 2:23 pm

Postby Sandy » Mon Dec 20, 2004 6:14 pm

Do you think this will work?


I have no idea, but the easiest way to tell is to try it :) .

Perhaps you haven't done this before. The easiest way to test is to highlite ONE msg in some mailbox; go to the script window that displays your script and hit the "Run on select msgs". The script will run on that msg. By trying different test msgs, you will see what happens. I sometimes insert "messagebox" lines into the script to display various variablesat various points in order to debug it if I need to -- there are probably better ways to do debug, but that is what I do.

BTW, if the script does move the msg to the junk folder, you can simply drag and drop it back to the original mailbox to test again.

Also note that I add a header to the msg to mark that that it was tagged by the script. You might want to change the initials from "sgm" to your initials.
Sandy
 

It worked!

Postby muncher1 » Tue Dec 21, 2004 1:59 am

Sandy,

I let it run overnight and this morning it caught 8 spams meeting the criteria. Changed the initials and set the count at 5. So far still blocking 100% of spams and allowing good emails to get through.

Thanks for the clue on how to test. Ran some junk through it this morning to get a feel for it. That makes it easy to test filters and scripts.

Chris
muncher1
Poco Tourist
 
Posts: 27
Joined: Sun Dec 19, 2004 2:23 pm

Help! Need to rework some of this code!

Postby muncher1 » Fri Jan 14, 2005 12:00 pm

This multiple recipient script has been working great and now I see one loop hole I need to close.

Since I have friends who are on the same domain as I and have run into dropping messages because it went to enough of us to trip the filter I need to tell the script to do this.

If anyone can take the below script and help rewrite it I would be most appreciative. By the way I haven't used the last subrountine in the code because I couldn't figure how to set it up.

-------------------
What I'd like to add:

1. Check the recipients;
2. If recipients is greater then number set;

then

3. check if any of the recipients are in my address book (besides myself);
4. if any are in address book allow message to come through;
5. if none of the multiple recipients are in my address book (besides myself)

then

6. flag it, don't download it, and delete from server.

if

7. Can't delete from server before download bring it to trash and delete.

Code: Select all
{  This script counts the number of times the string "austin.rr.com" appears
{  on the TO: and CC: lines; if there are more than #MaxNumber present
{  or the TO: or CC: lines contains one the special addresses found in the
{  CheckOtherAddresses subroutine, then the message is considered junkmail
{  it is moved to the $JunkMailbox folder
{
{  Author: Sandy (based on script by Slaven)
{  Written: 11/16/03
{  Modified:
{      11/1/04 - added subroutine to look for specific addresses
{
{  Notes:
{      Line numbers are zero based in PocoScript
{                                                                  
{   Modified 12/20/04:
{ Maximum Road Runner Recipients in Header found
{ If more then user input take to junk mailbox
{
  { ============ Process To fields =============== }

{ Define options in "Setup Script"
 External $userdata1 "Total Max Road Runner Recipients" "8"
 
{set up variables
Set #NumberFound 0
Set #SpecialAddressFound 0
Set #MaxNumber $userdata1
set $JunkMailbox "Trash.mbx"

{loop thru TO: line counting occurences of "austin.rr.com"
ReadTo $list %message
LineCount #n $list
Set #i 0

:LoopTo
If #i = #n then ProcessCC
GetLine $address #i $list
Trim $address
Set $email $address
Lowercase $email
{look for special addresses; if not found, continue to count
Call CheckOtherAddresses
StringPos #z "austin.rr.com" $email
If #z = 0 Then FinishedA1
Inc #NumberFound

:FinishedA1
Inc #i
Goto LoopTo

  { ============ Now process CC fields =============== }

{loop thru CC: line counting occurences of "austin.rr.com"
:ProcessCC
ReadCC $list %message
LineCount #n $list
Set #i 0

:LoopCC
If #i = #n then Finished
GetLine $address #i $list
Trim $address
Set $email $address
Lowercase $email                     
{look for special addresses; if not found, continue to count
Call CheckOtherAddresses
StringPos #z "austin.rr.com" $email
If #z = 0 Then FinishedA2
Inc #NumberFound

:FinishedA2
Inc #i
Goto LoopCC

  { =============== Finish processing ================}

{if there are more occurences than #MaxNumber, consider msg to be spam
:Finished
{add 1 to #MaxNumber so that if stat below is the equivalent of <=
Inc #MaxNumber
If #SpecialAddressFound = 1 Then AddsgmHeader
If #NumberFound < #MaxNumber then ExitNow
:AddsgmHeader
AddHeader %message "X-caf: " "sgmSpamMultiplexxxxx reject"
AppendToFile true
SaveMessage  %message $junkmailbox
DeleteMessage %message
Goto ExitNow

   { ============ Subroutines =======================}
{looks for specific addresses I have noticed only exist in spam
:CheckOtherAddresses
StringPos #y "sccready@xxxxx.com" $email
{if found, then msg is spam, so don't return to calling routine, just process as spam now
If #y = 0 Then ReturnNow
Inc #SpecialAddressFound
Goto Finished
:ReturnNow
Return

:ExitNow
muncher1
Poco Tourist
 
Posts: 27
Joined: Sun Dec 19, 2004 2:23 pm

Is this still the best way to do it?

Postby maverick » Sun Jan 01, 2006 10:32 am

I have pocomail 4.

Does this work for the current version?

And, more importantly, is this the BEST was to do it? Or can it be done with the junk mail tools builtin nowadays?

Maverick
maverick
Poco Tourist
 
Posts: 44
Joined: Sun Jan 01, 2006 10:29 am

Re: Is this still the best way to do it?

Postby Eric » Sun Jan 01, 2006 12:07 pm

maverick wrote:I have pocomail 4.
Does this work for the current version?
Yes, this does work with the current or previous version. :)
And, more importantly, is this the BEST was to do it? Or can it be done with the junk mail tools builtin nowadays?
What's the BEST way?
Some prefer to use the built-in Junk Mail filters or only the strict Bayesian filter. Others use scripts together with these filters.
:!: Best try out the built-in filters too, because then you'll know if they work for you.

You could also change the above script, so it would fit your need. :wink:
Eric
 

Re: Is this still the best way to do it?

Postby maverick » Sun Jan 01, 2006 2:29 pm

Eric wrote:...What's the BEST way?
Some prefer to use the built-in Junk Mail filters or only the strict Bayesian filter. Others use scripts together with these filters.
:!: Best try out the built-in filters too, because then you'll know if they work for you...


I dont see how I can use the builtin filters to put all cc:/bcc: mail (which is not addressed to me exclusively) into the Junk folder. Can you explain how to do this with the builtin tools?
maverick
Poco Tourist
 
Posts: 44
Joined: Sun Jan 01, 2006 10:29 am

Re: Is this still the best way to do it?

Postby Eric » Sun Jan 01, 2006 7:50 pm

maverick wrote:I dont see how I can use the builtin filters to put all cc:/bcc: mail (which is not addressed to me exclusively) into the Junk folder. Can you explain how to do this with the builtin tools?
I was talking in general, so not about this script. :oops:
:!: The Bayesian filter needs to learn about 1,000 bad & good words in order to kick in.
Be sure to enable it in Tools > Junk Mail Filters by checking the box.
You could eventually use the built-in filters, Bayesian, both or only strict Bayesian.
You could even use the above script & others together with your Junk Mail filters.
It's your preference after all, so try it out. :wink:
Eric
 

Postby maverick » Sun Jan 01, 2006 8:11 pm

I figured out how to get all my cc/bcc mail from addresses (not in my addressbook or acceptable list) sent to the bulk mail folder using the quickfilter tool. Now, all mail that is not 'plain' and not in my addressbook OR acceptable email address list automagically goes into the junk folder. I haven't gotton (so far) one piece of junk mail into my inbox. :)

Quickfilter is GREAT!!

I figured it out from another posting here on the boards.

Thanks everyone!
maverick
Poco Tourist
 
Posts: 44
Joined: Sun Jan 01, 2006 10:29 am

Postby Eric » Sun Jan 01, 2006 9:15 pm

You're welcome.
Good to know you found a topic which helped you with it. :)
And yes, the Quickfilter is really great. Like it very much, but don't forget the other great features (events, scripts, quote bar, ...) too, which Poco/Barca offers. :wink:
Eric
 

Postby FieldDir121 » Mon Jan 23, 2006 8:25 pm

I tried filtering based on multiple recipients. I put the filtered e-mails in a special mailbox. Most of the time they were spam. Occasionally the messages were really to me but included collegues, etc.

Since this can happen I had to look through all the extracted messages to make sure I wasn't missing one I needed to read, especially from my work account. A single missed product inquiry or delaying a customer looking for technical support can make a filter like this suddenly very costly.

Eventually I had to remove this filtering criteria. If you need to be able to receive e-mails from unknown senders, at least the first time they try to contact you, you may find this type of filtering to be too restrictive.

I have also noticed that many spam messages use BCC so I am one of two, and sometimes the only named recipient.

I was just passing by this topic and thought I would toss that in the hat.

Scott
FieldDir121
Resident Poster
 
Posts: 149
Joined: Mon Aug 02, 2004 5:18 pm


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron