Closed soulsymphonies closed 6 years ago
With the following query, you could just write "null" in the source_username field:
query = SELECT concat(destination_username, '@', destination_domain) as destinations FROM aliases WHERE source_username ='%u' and source_domain ='%d' and enabled = true UNION ALL SELECT concat(destination_username, '@', destination_domain) as destinations FROM aliases WHERE source_username = 'null' and source_domain ='%d' and enabled = true AND not exists (SELECT id FROM aliases WHERE source_username ='%u' and source_domain ='%d' and enabled = true);
But keep in mind that this way no user named null should exist.
This way you dont event need the source_username field to be null.
Hopes this helps you. Fabian
@soulsymphonies Thank you for using my GUI :)
I would suggest to go with @hibas123 solution (Thank you for helping out!). If the provided query is working I will add it to the docs, otherwise I want to collect more feedback before doing anything.
@phiilu I can confirm that the query of @hibas123 works as expected. Also, the identical query is given in the Questions and Answers section in Thomas Leister's official guide.
Thank you @Lonkey!
I added a link to the guide, unfortunately this guide is only available in german. Maybe Thomas will also add it to the english version in the future.
thank you ever so much for all your efforts, sorry for the late reply, lot's of things happened in my life that I had to address.
I think this solution covers it. Thanks again.
i edited @hibas123 query to:
query = SELECT concat(destination_username, '@', destination_domain) as destinations FROM aliases WHERE source_username ='%u' and source_domain ='%d' and enabled = true UNION ALL SELECT concat(destination_username, '@', destination_domain) as destinations FROM aliases WHERE source_username = '*' and source_domain ='%d' and enabled = true AND not exists (SELECT id FROM aliases WHERE source_username ='%u' and source_domain ='%d' and enabled = true);
so you could just write "*" in the source_username field instant of "null"
First of all, thank you for this great GUI, unfortunately I'm not a programmer.
Would it be possible to extend the "Add Alias" and "Edit Alias" webforms so that the username can actually be set 'null' in the database which would allow for "catchall" mail adresses to be created.
Maybe by adding a checkbox, to set it 'null' instead of the username additionally to the normal username input field.
To realize the catchall with the database, I have changed the database according to the advice on https://thomas-leister.de/mailserver-debian-stretch with this query:
alter table aliases modify source_username varchar(64) null;
And I have adjusted the query in the aliases.cf as well, as it says on Leisteres article:
query = SELECT concat(destination_username, '@', destination_domain) as destinations FROM aliases WHERE source_username ='%u' and source_domain ='%d' and enabled = true UNION ALL SELECT concat(destination_username, '@', destination_domain) as destinations FROM aliases WHERE source_username is null and source_domain ='%d' and enabled = true AND not exists (SELECT id FROM aliases WHERE source_username ='%u' and source_domain ='%d' and enabled = true);
Just let me know.
Many thanks, Robert