kekskurse / go-mail-admin

HTTP-Interface with a small GUI for a Mailserver
GNU General Public License v3.0
32 stars 5 forks source link

Support catch-all accounts #5

Closed fnetX closed 4 years ago

fnetX commented 4 years ago

Currently, creating a catch-all account as of the tutorial of thomas leister (setting the source_username to MySQL-NULL) is unsupported.

There is apparently no way to do so in the web config and doing it manually causes go-mail-admin to exit on table retrieval with:

sql: Scan error on column index 1, name "source_username": converting NULL to string is unsupported

and exit code 1.

Please

I will have a look at it, but I'd be very glad about support. But I do understand if this issue is not urgent for you as you apparently don't need catch-all aliases ...

Thank you very much.

kekskurse commented 4 years ago

I will have a look tomorrow, i have an idea how I can add a possible to manage catchall.

fnetX commented 4 years ago

Thank you very much. As a workaround I modified the SQL queries to use * for catch-all accounts. I'd be okay with this, but it might be a good idea to mention this - or create a "feature list" of what is supported and what isn't.

Off-topic, but if you need help with any specific tasks over here (whether documentation or software updates) please let me know. I'm glad if I could try and help you with something :wink:

kekskurse commented 4 years ago

Sorry that it takes so long. I try to reproduce the issue. source_username is a field in the aliases table, that field is based on the query from thomas-leister.de not null.

CREATE TABLE `aliases` (
    `id` int unsigned NOT NULL AUTO_INCREMENT,
    `source_username` varchar(64) NOT NULL,
    `source_domain` varchar(255) NOT NULL,
    `destination_username` varchar(64) NOT NULL,
    `destination_domain` varchar(255) NOT NULL,
    `enabled` boolean DEFAULT '0',
    PRIMARY KEY (`id`),
    UNIQUE KEY (`source_username`, `source_domain`, `destination_username`, `destination_domain`),
    FOREIGN KEY (`source_domain`) REFERENCES `domains` (`domain`)
);

Is your database changed that it allow NULL Values? And did a empty string "" works as catch all too?

fnetX commented 4 years ago

Hey, I'm sorry. I used the tutorial for Debian Buster for a new mailing solution and didn't recall that Catchalls was no official feature in the past tutorial, I added it by myself the last time. I already noticed that the source_username field changed in the next version.

However, the NULL-approach is used in the next Buster tutorial. You could try to support that, but I guess I'll try to propose the asterisk approach to him as I think that it's somewhat more intuitive and as far as I could see only few of the other admin solutions support it.

kekskurse commented 4 years ago

After changing the MySQL

ALTER TABLE aliases MODIFY source_username varchar(64) NULL;

I can reproduce the issue and have fix it. There will be a FeatureToggle to enabled the catchall in the API and Frontend, so the other Version with NOT NULL will work too. In the Version 0.1.3 will be a enviroment variable "GOMAILADMIN_CATCHALL" which can set to "On" to enabled it.