EmailDiscussions.com  

Go Back   EmailDiscussions.com > Email Service Provider-specific Forums > FastMail Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Stay in touch wirelessly

FastMail Forum All posts relating to FastMail.FM should go here: suggestions, comments, requests for help, complaints, technical issues etc.

Reply
 
Thread Tools
Old 6 Nov 2022, 12:56 PM   #1
unusable1281
Junior Member
 
Join Date: Nov 2022
Posts: 4
Sieve question: using regex to filter catch all address.

Every time when I create a (pseudo) "random" address to use catch-all, I want to create it when a certain rule that I can use regex sieve filter later.

For example, my email address is 785abc@testdomain.com, and the rule for this email address is

last digit = (1st digit + 2nd digit)%10.
5 = (7+8)%10

If I always use this rule to create aliases, I can then use a sieve filter to reject all email addresses that don't follow this rule.

My question is how can I utilize regex and sieve to create a filter like this?

Last edited by unusable1281 : 7 Nov 2022 at 02:25 AM.
unusable1281 is offline   Reply With Quote

Old 6 Nov 2022, 05:11 PM   #2
BritTim
The "e" in e-mail
 
Join Date: May 2003
Location: mostly in Thailand
Posts: 3,049
How is your requirement different from saying that you want to look for a single numeric digit rather than 2 numeric digits in your match? I am puzzled, not really understanding what you are trying to achieve. Perhaps, an example original address and 'random alias' address might help to clarify.
BritTim is offline   Reply With Quote
Old 7 Nov 2022, 03:16 AM   #3
unusable1281
Junior Member
 
Join Date: Nov 2022
Posts: 4
Quote:
Originally Posted by BritTim View Post
How is your requirement different from saying that you want to look for a single numeric digit rather than 2 numeric digits in your match? I am puzzled, not really understanding what you are trying to achieve. Perhaps, an example original address and 'random alias' address might help to clarify.
Thanks for your reply. The rule is like this.

last digit = (1st digit + 2nd digit)%10.

abc123@testdomain.com, PASS, 1+2=3, and the last digit is 3.
abc124@testdomain.com, FAIL, 1+2=3, but the last digit is 4.
abc678@testdomain.com, FAIL, (6+7)%10=3, but the last digit is 8.
abc673@testdomain.com, PASS, (6+7)%10=3, and the last digit is 3.

If someone sends me an email that doesn't follow the rule I created, it should be spam, and it can be rejected automatically using this rule. Also, anyone can use this idea to generate their own rule. For example, they might have more digits, or they may want to use +-*/ or whatever they want. But, the problem is I have no idea how to create this rule or is it possible to create a rule like this.
unusable1281 is offline   Reply With Quote
Old 7 Nov 2022, 03:56 AM   #4
BritTim
The "e" in e-mail
 
Join Date: May 2003
Location: mostly in Thailand
Posts: 3,049
I think the only way of achieving this with normal regular expressions will be by use of alternatives, something like
Code:
abc(
(00|19|28|37|46|55|64|73|82|91)0 | 
(01|10|29|38|47|56|65|74|83|92)1 |
(02|11|20|39|48|57|66|75|84|93)2 [ 
(03|12|21|30|49|58|67|76|85|94)3 | 
(04|13|22|31|40|59|68|77|86|95)4 | 
(05|14|23|32|41|50|69|78|87|96)5 | 
(06|15|24|33|42|51|60|79|88|97)6 | 
(07|16|25|34|43|52|61|70|89|98)7 |
(08|17|26|35|44|53|62|71|80|99)8 | 
(09|18|27|36|45|54|63|72|81|90)9 
)@testdomain.com
(obviously, I added some white space that would need to be removed after carefully checking for typos)

Some special regular expression extensions would probably allow a less ugly solution, but sieve is not going to support those.
BritTim is offline   Reply With Quote
Old 7 Nov 2022, 04:54 AM   #5
unusable1281
Junior Member
 
Join Date: Nov 2022
Posts: 4
Thanks for your answer. It seems like this is a too-advanced requirement that cannot be resolved.
unusable1281 is offline   Reply With Quote
Old 7 Nov 2022, 08:53 AM   #6
SideshowBob
Essential Contributor
 
Join Date: Jan 2017
Posts: 243
I used to use fixed format subdomain addresses that used a combination of a mnemonic and the year and month e.g. for this site I might have used emd2211@... My sieve script did check that it was the right format with exactly 4 digits matching sensible valid dates, but I never saw any attempt by spammers to make-up similar addresses. I don't think it's much of a problem. Using a subdomain may help to make it clear that there's no point in making-up addresses.

The reason I included the year+month is to prevent me from reusing an address, but for a 10 year window it gives a 1% risk of an accidental match on an address ending in 4 random digits compared with 10% for the modulo 10 test.
SideshowBob is offline   Reply With Quote
Old 7 Nov 2022, 10:53 AM   #7
unusable1281
Junior Member
 
Join Date: Nov 2022
Posts: 4
Quote:
Originally Posted by SideshowBob View Post
I used to use fixed format subdomain addresses that used a combination of a mnemonic and the year and month e.g. for this site I might have used emd2211@... My sieve script did check that it was the right format with exactly 4 digits matching sensible valid dates, but I never saw any attempt by spammers to make-up similar addresses. I don't think it's much of a problem. Using a subdomain may help to make it clear that there's no point in making-up addresses.

The reason I included the year+month is to prevent me from reusing an address, but for a 10 year window it gives a 1% risk of an accidental match on an address ending in 4 random digits compared with 10% for the modulo 10 test.
Thanks for your suggestion. This is a good idea. The rule I mentioned above is a toy example. In reality, I can create other more sophisticated rules using this idea if I know how to make something like this...
Also, do you mind sharing how to use a sieve to build the filter you mentioned?

Last edited by unusable1281 : 7 Nov 2022 at 02:27 PM.
unusable1281 is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +9. The time now is 08:37 PM.

 

Copyright EmailDiscussions.com 1998-2022. All Rights Reserved. Privacy Policy