[exim-dev] $message_body empty in the Router Condition

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Jeffrey Rigby
Datum:  
To: exim-dev
Betreff: [exim-dev] $message_body empty in the Router Condition
I'm having issues with headers and body variables returning null when called in router conditions. My goal is to select a router/transport based on either:

- A string appearing in the body of the email (preferred), or
- The value of a custom header

For example, if I have the string "router:1" in the email body I want to use a particular router with a condition that searches for router:1 in $message_body.

Here's are my two defined routers:

send_via_extsmtp:
driver = manualroute
domains = ! +local_domains
transport = extsmtp_smtp
route_list = "* mail.optonline.net::587 byname"
host_find_failed = defer
condition = ${if match{$message_body}{router:1}}
headers_add = "X-ROUTER-TEST: ${if match{$message_body}{router:1}}"
no_more

send_via_extsmtp_nofilter:
driver = manualroute
domains = ! +local_domains
transport = extsmtp_smtp_nofilter
route_list = "* mail.optonline.net::587 byname"
host_find_failed = defer
condition = ${if match{$message_body:}{router:2}}
no_more


The $message_body is seemingly always null. Here's what it outputs in the debug log:

15:49:54 71560 checking "condition"
15:49:54 71560 expanding: NULL
15:49:54 71560    result: NULL
15:49:54 71560 considering bool_lax: NULL
15:49:54 71560 expanding: $message_body
15:49:54 71560    result:
15:49:54 71560 expanding: router:1
15:49:54 71560    result: router:1
15:49:54 71560 condition: match{$message_body}{router:1}
15:49:54 71560    result: false
15:49:54 71560 expanding: ${if match{$message_body}{router:1}}
15:49:54 71560    result:
15:49:54 71560 considering bool_lax: <empty>
15:49:54 71560 condition: and{{bool_lax{NULL}}{bool_lax{${if match{$message_body}{router:1}}}}}
15:49:54 71560    result: false
15:49:54 71560 expanding: ${if and{{bool_lax{NULL}}{bool_lax{${if match{$message_body}{router:1}}}}}}
15:49:54 71560    result:
15:49:54 71560 send_via_extsmtp router skipped: condition failure


I've tried the same thing with headers and it's always NULL and the condition always fails.

Oddly, it's not empty when I copy the same exact condition to headers_add:
headers_add = "X-ROUTER-TEST: ${if match{$message_body}{router:1}}"

The email is sent with the header:
X-ROUTER-TEST: true

This condition also works in a system_filter.

It seems the only place I'm not seeing it is in the condition router config.

Is there something obvious that I'm missing? Should I handle this another way?

Thanks!
Jeff