Difference between revisions of "RTAddressRegexp"

From Request Tracker Wiki
Jump to navigation Jump to search
 
m (8 revisions imported)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
$'''RT''''''Address''''''Regexp''' is used to prevent RT messaging itself and generating mail loops, for example when $[[ParseNewMessageForTicketCcs]] is enabled and other. Anyway to protect you from loops and other problems you must set up this option.
'''$RTAddressRegexp''' is used to prevent RT messaging itself and generating mail loops, for example when $[[ParseNewMessageForTicketCcs]] is enabled and other. Anyway to protect you from loops and other problems you must set up this option.


In this option you '''MUST''' cover every email address that can be used to interact with RT via email. If you have aliases of redirect messages to RT from some address those also should be covered.
In this option you '''MUST''' cover every email address that can be used to interact with RT via email. If you have aliases of redirect messages to RT from some address those also should be covered.
Line 5: Line 5:
An example expression:
An example expression:


  Set($RTAddressRegexp , '^help(-comment)?\@(help|admin)\.(example\.org|ourother\.domain\.com)$');]
  Set($RTAddressRegexp , '^help(-comment)?\@(help|admin)\.(example\.org|ourother\.domain\.com)$');


Would work for a server with the names "help" and "admin" and multiple domains. This will catch:
Would work for a server with the names "help" and "admin" and multiple domains. This will catch:
Line 31: Line 30:
* escaped: <code>bugs\@my\.com</code>, <code>bugs-comment\@my\.com</code>, <code>sales\@my\.com</code> and <code>sales-comment\@my\.com</code>
* escaped: <code>bugs\@my\.com</code>, <code>bugs-comment\@my\.com</code>, <code>sales\@my\.com</code> and <code>sales-comment\@my\.com</code>
* regexp: <code>^(bugs\@my\.com|bugs-comment\@my\.com|sales\@my\.com|sales-comment\@my\.com)$</code>
* regexp: <code>^(bugs\@my\.com|bugs-comment\@my\.com|sales\@my\.com|sales-comment\@my\.com)$</code>
* <code>^(bugs|sales)(-comment)?\@(my\.com)$</code>


As you can see this can get very long if there are several names for the server.
As you can see this can get very long if there are several names for the server.
Line 41: Line 41:
* <code>.</code> - matches any character, so you usually should escape them
* <code>.</code> - matches any character, so you usually should escape them
* <code>@</code> - is used to access arrays, so you escape it to match @ literaly
* <code>@</code> - is used to access arrays, so you escape it to match @ literaly
* <code>^</code> and <code>$</code> - match at begin and end of the string respectively, note that regexp <code>rt\@example\.com</code> would match robert@example.com and rt@example.com.au addresses, most probably '''it's not''' what you want, use <code>^rt\@example\.com$</code> regexp.
* <code>^</code> and <code>$</code> - match at begin and end of the string respectively, note that regexp <code>rt\@example\.com</code> would match robert@example.com and rt@example.com.au addresses, most probably '''it is not''' what you want, use <code>^rt\@example\.com$</code> regexp.
* <code>()</code> - group things, often used with <code>|</code> to group alternatives
* <code>()</code> - group things, often used with <code>|</code> to group alternatives
* <code>|</code> - separator for alternative parts, note that <code>^rt\@foo\.com|rt\@bar\.com$</code> matches rt@foo.com.au and robert@bar.com as <code>^</code> applies to the left alternative part and <code>$</code> to the right only, so you can ready this expression as "address starts with rt@foo.com or ends with rt@bar.com". You must group alternatives <code>^(rt\@foo\.com|rt\@bar\.com)$</code>
* <code>|</code> - separator for alternative parts, note that <code>^rt\@foo\.com|rt\@bar\.com$</code> matches rt@foo.com.au and robert@bar.com as <code>^</code> applies to the left alternative part and <code>$</code> to the right only, so you can read this expression as "address starts with rt@foo.com or ends with rt@bar.com". You must group alternatives <code>^(rt\@foo\.com|rt\@bar\.com)$</code>
* <code>?</code> - makes precedence atom optional, for example <code>^rt(-comment)?\@example\.com$</code> matches rt@example.com and rt-comment@example.com
* <code>?</code> - makes previous atom optional, for example <code>^rt(-comment)?\@example\.com$</code> matches rt@example.com and rt-comment@example.com


== See also ==
== See also ==


[[EmailInterface]] and [[SiteConfig]]
[[EmailInterface]] and [[SiteConfig]]

Latest revision as of 16:24, 6 April 2016

$RTAddressRegexp is used to prevent RT messaging itself and generating mail loops, for example when $ParseNewMessageForTicketCcs is enabled and other. Anyway to protect you from loops and other problems you must set up this option.

In this option you MUST cover every email address that can be used to interact with RT via email. If you have aliases of redirect messages to RT from some address those also should be covered.

An example expression:

Set($RTAddressRegexp , '^help(-comment)?\@(help|admin)\.(example\.org|ourother\.domain\.com)$');

Would work for a server with the names "help" and "admin" and multiple domains. This will catch:

help@help.example.org
help-comment@help.example.org
help@admin.example.org
.
.
.
help-comment@admin.ourother.domain.com

Simple way

If you don't understand perl regular expression you can use simple way:

  • collect list of addresses you must cover
  • escape . (dot), @ and + symbols with \
  • fill them into template ^(escaped address 1|escaped address 2|escaped address 3|...)$

Example:

  • addresses: bugs@my.com, bugs-comment@my.com, sales@my.com and sales-comment@my.com
  • escaped: bugs\@my\.com, bugs-comment\@my\.com, sales\@my\.com and sales-comment\@my\.com
  • regexp: ^(bugs\@my\.com|bugs-comment\@my\.com|sales\@my\.com|sales-comment\@my\.com)$
  • ^(bugs|sales)(-comment)?\@(my\.com)$

As you can see this can get very long if there are several names for the server.

Regexp rules you must know

Short perl regexps rules you must know:

  • \ - is used to escape character with special meaning, like dot, @, parens and other
  • . - matches any character, so you usually should escape them
  • @ - is used to access arrays, so you escape it to match @ literaly
  • ^ and $ - match at begin and end of the string respectively, note that regexp rt\@example\.com would match robert@example.com and rt@example.com.au addresses, most probably it is not what you want, use ^rt\@example\.com$ regexp.
  • () - group things, often used with | to group alternatives
  • | - separator for alternative parts, note that ^rt\@foo\.com|rt\@bar\.com$ matches rt@foo.com.au and robert@bar.com as ^ applies to the left alternative part and $ to the right only, so you can read this expression as "address starts with rt@foo.com or ends with rt@bar.com". You must group alternatives ^(rt\@foo\.com|rt\@bar\.com)$
  • ? - makes previous atom optional, for example ^rt(-comment)?\@example\.com$ matches rt@example.com and rt-comment@example.com

See also

EmailInterface and SiteConfig