Finally I got back to this topic.

Okay, I did some reading and know that I can use $local_part in my SQL queries like before. Here's an example, they all look similar:

SQL_MAILDIR = \
        select maildir \
        from mail_entries \
        where local = lower('${quote_pgsql:$local_part}') and domain = 
lower('${quote_pgsql:$domain}') and maildir <> ''

The only remaining use of $local_part in a context where its value is actually relevant is a redirect router:

# If recipient is a mailbox on its own, deliver the message.
# This router is used for mailboxes that have a Sieve filter defined.
virtual_user_filter:
        driver = redirect
        local_part_suffix = +*
        local_part_suffix_optional
        allow_fail
        allow_defer
        allow_filter
        user = Debian-exim
        data = ${lookup pgsql{SQL_FILTER}{$value}}
        address_data = ${lookup pgsql{SQL_QUOTA}{$value}fail}
        file_transport = address_directory
        reply_transport = address_reply
        sieve_useraddress = $local_part
        sieve_subaddress = ${sg{$local_part_suffix}{^.}{}}
        sieve_vacation_directory = /var/mail/sieve/$local_part@$domain/vacation

Here the variable defines the Sieve configuration (last 3 lines). I haven't looked up the 'sieve_useraddress' option but the other one definitely constructs a file path.

This router, however, is only used if the local_part has been successfully looked up by a prior SQL query. So by the time we're here, I know that the value is valid.

What I'm not sure about is whether I can use the variable or should use the same value from the database lookup instead. There might be slight differences like whitespace or whatever. If I need the lookup result, how would I get that? Need to do a separate query like this?

select local_part
from mail_entries
where local = lower('${quote_pgsql:$local_part}')
  and domain = lower('${quote_pgsql:$domain}')

That $local_part_data variable seems only be set when using OS-native users for the mailboxes, which I don't. So I probably can't use it at all.

-Yves


-------- Ursprüngliche Nachricht --------
Von: Jasen Betts via Exim-users <exim-users@lists.exim.org>
Datum: 2025-03-21 04:53 +01:00
Betreff: [exim] Re: Upgrading Exim to 4.94: $local_part vs. $local_part_data

On 2025-03-18, Yves Goergen via Exim-users <exim-users@lists.exim.org> wrote:
Hello,

I'm upgrading Exim from 4.93 to 4.97 soon and read an entry in the
upgrading documentation [1]. It says I cannot use $local_part in
transports anymore and should consider $local_part_data.

For some purposes you cannot use $local_part, what are you using it for?

Unfortunately, I'm not an Exim expert so I don't know what consequences
that will have. A web search hasn't brought up any information on this.
I'm using $local_part in transports, routers and ACLs, it's basically
everywhere. I mean, it's the most essential data to identify a mailbox.

What should I do now? Can I simply replace that variable everywhere?

You can use it as the key in a lookup and use the result to identify the
mailbox file.  $local_part_data is an exmple of that, but explicit lookups
are allowed too.

It's also part of SQL queries in macros which are called from different
parts of the config file. If I need to use different variables in
different contexts now, I'd have to duplicate those SQL queries to use
different variables.

Assuming it's being quoted properly the SQL queries can most likely
remain as-is but if you're using "servers=" that part may need to be
rearranged.


--
## subscription configuration (requires account):
##   https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
##   exim-users-unsubscr...@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

Reply via email to