Information: Forum is in read-only mode
For details and other support options see https://www.adiscon.com/news/support-forum-set-to-read-only-mode/

How to save and reuse the matching word from $msg

General discussions here

Moderator: alorbach

Google Ads


How to save and reuse the matching word from $msg

Postby RASG » Tue Feb 27, 2018 5:50 pm

I want to save mail logs by domain, each having it's own file.

So myfirstdomain.com log messages would go to /var/log/mail/myfirstdomain.log

And myseconddomain.bla would be saved in /var/log/mail/myseconddomain.log

Instead of writing multiple conditionals like below

Code: Select all
if $msg contains "@myfirstdomain.com" then {
    action(type="omfile"
        file="/var/log/mail/myfirstdomain.log"
        name="action-omfile-myfirstdomain"
    )
}

if $msg contains "@myseconddomain.bla" then {
    action(type="omfile"
        file="/var/log/mail/myseconddomain.log"
        name="action-omfile-myseconddomain"
    )
}


I was thinking about a 'one rule fits all' approach like

Code: Select all
if $msg contains [
    "@myfirstdomain.com",
    "@myseconddomain.bla"
] then {

    set $!domain = \captured domain from above\
   
    action(type="omfile"
        file="/var/log/mail/$!domain.log"
        name="action-omfile-$!domain"
    )
}


Is it possible?

How do i use only the text part that matched the conditional? (the domain, in this case).
RASG
New
 
Posts: 1
Joined: Tue Feb 27, 2018 5:09 pm

Urgent Question?

  • Pulling out your Hair?
  • Wasting Time and Money?
  • Deadline Approaching?

Google Ads


Return to General

Who is online

Users browsing this forum: No registered users and 0 guests

cron