SOLVED

Block messages with white space at the beginning of subject

Copper Contributor

Hi!

This is my first post here.

We have transport rule that prevents users from sending e-mail messages with blank subject. However, users tend to enter only space and send message without any other character. 

What regular expression would you suggest for transport rule to match this rule?

 

Thanks!

2 Replies
best response confirmed by Thomas Stensitzki (MVP)
Solution

You'd want to use the \s regex filter, which catches any whitespace.
Your final regex should look like this:

^\s+$

The ^ marks the beginning of the line, + indicates we are looking for any combination of whitespace (from a single character to many repeating whitespaces), and $ marks the end of the line. You can try this out at a regex expression evaluation site like this: https://regexr.com/3s12e

 

I would highly recommend testing this by putting it in audit mode or applying it to a test user first. Transport rules should always be tested first

 

To create your transport rule:

1. Create a New Transport Rule

2. Hit 'More Options' at the bottom

3. Select 'Apply this rule if...'

4. Select 'Subject matches these text patterns'

5. Enter the regex

6. Enter any other conditions if needed

7. Select the action to perform (block message)

 

I tried with single space in message subject, but message was delivered to user.

 

BLANK_SUBJECT_O365.PNG

 

1 best response

Accepted Solutions
best response confirmed by Thomas Stensitzki (MVP)
Solution

You'd want to use the \s regex filter, which catches any whitespace.
Your final regex should look like this:

^\s+$

The ^ marks the beginning of the line, + indicates we are looking for any combination of whitespace (from a single character to many repeating whitespaces), and $ marks the end of the line. You can try this out at a regex expression evaluation site like this: https://regexr.com/3s12e

 

I would highly recommend testing this by putting it in audit mode or applying it to a test user first. Transport rules should always be tested first

 

To create your transport rule:

1. Create a New Transport Rule

2. Hit 'More Options' at the bottom

3. Select 'Apply this rule if...'

4. Select 'Subject matches these text patterns'

5. Enter the regex

6. Enter any other conditions if needed

7. Select the action to perform (block message)

 

View solution in original post