I'm trying to route messages to a smarthost using a manualroute, based
on the From address of the message, and if the From address isn't listed
then deliver the message normally (i.e. dnslookup). For some reason
$header_from: and $sender_address are empty though. Any idea why, and/or
how I can use those variables?
Here's what I have so far, this is placed just below the begin routers
line in my exim.conf. This might get word-wrapped but the route_data
line is all one long line in my config.
from_based_routing:
driver = manualroute
domains = !+local_domains
transport = remote_smtp
route_data = ${lookup mysql{select smarthost from routing_table where
from=\"${quote_mysql:$sender_address}\"}}
In the MySQL log I see it doing a query like this:
select smarthost from routing_table where from=""
Without this in place I can send mail fine through the server. I'm just
using Outlook Express (ugh) to test with. When the message comes through
it shows up with the From: address just fine. There is no Return-Path in
the header but there definitely is a From: line, e.g. From: "Jeremy"
<test@???>
I have also tried these variations with no luck:
route_data = ${lookup mysql{select smarthost from routing_table where
from=\"${quote_mysql:$header_from:}\"}}
route_data = ${lookup mysql{select smarthost from routing_table where
from=\"$header_from:\"}}
route_data = ${lookup mysql{select smarthost from routing_table where
from=\"$sender_address\"}}
I also tried this just for the heck of it...
route_data = ${lookup mysql{select smarthost from routing_table where
from=\"$sender_address:\"}}
...and the MySQL log changed to this as expected:
select smarthost from routing_table where from=":"