Hi
Further to my earlier emails disposable mail aliases, I found I have bug in my
filter script when there are two recipients of an alias.
An incoming email's address may be mapped into several recipients. Currently
these are concatenated into a comma-delimited list, for example:
"recipient1,recipient2"
And this is fed to the deliver command via a (regex capture) variable,
effectively resulting in this:
deliver "recipient1,recipient2"
I had thought this string would be processed by the "deliver" command in the
same way lists in the /etc/aliases file are. But it is rejected with an error:
error in filter file: malformed address "recipient1,recipient2" in
filter file: missing or malformed local part (expected word or "<")
So apparently this doesn't work like I thought. However I cannot easily just
split this into two 'deliver' commands as the filter docs say: the variable may
contain an arbitrary number of recipients.
Does anyone know a way to persuade 'deliver' to send to multiple recipients?
I've tried various delimiters (notably commas, spaces, newlines). Or
alternatively, a way to map a variable containing several recipients into
several invocations of the deliver command?
To elaborate, the part of the filter which does this is a sqlite expansion:
"${lookup sqlite{/var/spool/exim4/db/disposable-aliases.db \
select coalesce(group_concat(recipients, ','), '') from aliases \
where stem = '${quote_sqlite:$local_part}'} \
{$value}{}}"
'aliases' is a table with a two fields, mapping local-part 'stem' strings to one
or more recipient addresses.
CREATE TABLE aliases (
stem TEXT NOT NULL,
recipients TEXT NOT NULL,
PRIMARY KEY (stem, recipients)
);
So when there are two records for a given alias stem:
'alias1', 'recipient1'
'alias1', 'recipient2'
The result for an email to the 'alias1' stem is delivery to 'recipient1,recipient2'.
Thanks
Nick