Delete user without prompt but keep mailbox data#4565
Delete user without prompt but keep mailbox data#4565georglauterbach merged 1 commit intodocker-mailserver:masterfrom
Conversation
|
This doesn't seem to be necessary? I think it would be better to avoid the issue entirely by ensuring you run commands non-interactively, without needing to patch support in per command as-needed 😅 You want the default logic of this command, but your concern is the interactive prompt when you call the command non-interactively?: $ setup email del [email protected]
Do you want to delete the mailbox data as well (removing all mails)? [y/N]This script handles the prompt by reading from stdin, so you can just pipe in the echo 'n' | setup email del [email protected]
2025-09-04 00:30:46+00:00 INFO delmailuser: The mailbox data will not be deleted.
2025-09-04 00:30:46+00:00 INFO delmailuser: '[email protected]' and associated data (aliases, quotas) deletedOr from the docker host when calling into the container you can wrap that like this: docker exec dms bash -c 'echo "n" | setup email del [email protected]'Since I omitted Sending a command from outside of the container via the docker hostThis is for a quick reference, if you're interested in the details to better understand this advice, I've covered that in the next section. $ docker run --rm \
--env ACCOUNT_PROVISIONER=FILE \
--volume ./postfix-accounts.cf:/tmp/docker-mailserver/postfix-accounts.cf:ro \
ghcr.io/docker-mailserver/docker-mailserver:15.1.0 \
setup email del [email protected]
2025-09-04 01:06:43+00:00 INFO delmailuser: The mailbox data will not be deleted.
sed: cannot rename /tmp/docker-mailserver/sedauD0Xw: Device or resource busy
2025-09-04 01:06:43+00:00 ERROR delmailuser: '[email protected]' could not be deleted
2025-09-04 01:06:43+00:00 ERROR delmailuser: Aborting
services:
dms:
image: ghcr.io/docker-mailserver/docker-mailserver:15.1.0
volumes:
- ./postfix-accounts.cf:/tmp/docker-mailserver/postfix-accounts.cf:ro# Only `--no-TTY` => Prompt is hidden but otherwise remains interactive
# Only `--interactive=false` => Prompt appears and hangs as no input can actually be received
# Both opt-out flags => No prompt shown and no stdin to receive input, proper non-interactive shell
$ docker compose run --rm --no-TTY --interactive=false \
--env ACCOUNT_PROVISIONER=FILE \
dms \
setup email del [email protected]
2025-09-04 01:06:43+00:00 INFO delmailuser: The mailbox data will not be deleted.
sed: cannot rename /tmp/docker-mailserver/sedauD0Xw: Device or resource busy
2025-09-04 01:06:43+00:00 ERROR delmailuser: '[email protected]' could not be deleted
2025-09-04 01:06:43+00:00 ERROR delmailuser: Aborting
|
|
Oh, I just saw https://gitlab.com/div-solutions/docker-mailserver-ui is referring to k8s. Kubernetes is rather slow at resolving issues with landing capabilities that Docker has, so if it lacks the equivalent ability to run a command non-interactively perhaps the support in DMS is necessary? @cfis or @georglauterbach can probably chime in on that? We could technically infer lack of stdin via I'll wait on feedback from other maintainers. |
|
I believe you want: Add |
|
Thanks for your reply @polarathene. I can use 'echo "n" | setup email del [email protected]' My process of thinking was, because my code to execute setup though k8s client in .net looks like this: so if there is -y, why not -n, doesn't impact feature in any way except adding new parameter for promptless deletion 😄 If this is too much of an issue, I will just modify my execution function to insert the echo n. Thanks |
|
I'm not against the change, I was just curious if you could run the command non-interactively without needing that support whenever a command has an interactive prompt. I'll leave the PR up to @casperklein or @georglauterbach to decide if we should include flags for skipping prompts to use defaults. It's probably still a valid use-case, you're just the first user I've seen bring it up :) |
|
I am fine with this change. @casperklein what do you make out of this? |
|
|
e78801b
into
docker-mailserver:master
Description
Added option to allow to delete email but do not delete email data without prompt using "-n", default and "-y" remains as is.
Its required for UI I made and I want to allow admin to delete email without deleting data.
https://gitlab.com/div-solutions/docker-mailserver-ui
Type of change
Checklist
docs/)CHANGELOG.md