phiilu / mailman

Mailman is a GUI to help you manage your email accounts stored in a MySQL/MariaDB database.
MIT License
70 stars 10 forks source link

Adjustment request for catchall adresses in the alias table #11

Closed soulsymphonies closed 6 years ago

soulsymphonies commented 6 years ago

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

hibas123 commented 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

phiilu commented 6 years ago

@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.

ghost commented 6 years ago

@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.

phiilu commented 6 years ago

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.

soulsymphonies commented 6 years ago

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.

T0biii commented 6 years ago

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"