Mail alias for all_users

Hello, I would like to define a mail alias to send messages to every account of my server.

I tried as explained here to define a mail-alias to the all_users group, but it doesn’t seem to be allowed :

> yunohost user group add-mailalias all_users <my-mail-alias>
Error: The group 'all_users' cannot be edited manually. It is a special group meant to contain all users registered in YunoHost

One solution would be to create another group manually, which would contain every users, but I’d like to avoid this as it’d be redundant with the all_users group.

Is there another solution ? Could the YuNoHost policy about the all_users mail aliases be changed ?

Thanks fo your answers.

Try the same command with --force. :wink:

Hi,
The argument --force is unrecognized…

Oooops indeed! It looks like an oversight in the code. Let’s hack a little bit to circumvent that, while we wait for an update of YunoHost.

/usr/lib/python3/dist-packages/yunohost/user.py

Run the following command: nano +1366 /usr/lib/python3/dist-packages/yunohost/user.py

Around that line, there is the following code:

def user_group_add_mailalias(groupname, aliases):
    return user_group_update(groupname, add_mailalias=aliases, sync_perm=False)


def user_group_remove_mailalias(groupname, aliases):
    return user_group_update(groupname, remove_mailalias=aliases, sync_perm=False)

Update it for it to look like this:

def user_group_add_mailalias(groupname, aliases, force=False):
    return user_group_update(groupname, add_mailalias=aliases, force=force, sync_perm=False)


def user_group_remove_mailalias(groupname, aliases, force=False):
    return user_group_update(groupname, remove_mailalias=aliases, force=force, sync_perm=False)

Close and save with CTRL+O then CTRL+X.

/usr/share/yunohost/actionsmap.yml

Then open another file with nano +325 /usr/share/yunohost/actionsmap.yml. Around these lines there should be:

                add-mailalias:
                    action_help: Add mail aliases to group
                    api: PUT /users/groups/<groupname>/aliases/<aliases>
                    arguments:
                        groupname:
                            help: Name of the group to add user(s) to
                            extra:
                                pattern: *pattern_groupname
                        aliases:
                          help: Mail aliases to add
                          nargs: "+"
                          metavar: MAIL
                          extra:
                              pattern: *pattern_email
                remove-mailalias:
                    action_help: Remove mail aliases to group
                    api: DELETE /users/groups/<groupname>/aliases/<aliases>
                    arguments:
                        groupname:
                            help: Name of the group to add user(s) to
                            extra:
                                pattern: *pattern_groupname
                        aliases:
                          help: Mail aliases to remove
                          nargs: "+"
                          metavar: MAIL

Update it for it to look like this:

                add-mailalias:
                    action_help: Add mail aliases to group
                    api: PUT /users/groups/<groupname>/aliases/<aliases>
                    arguments:
                        groupname:
                            help: Name of the group to add user(s) to
                            extra:
                                pattern: *pattern_groupname
                        aliases:
                          help: Mail aliases to add
                          nargs: "+"
                          metavar: MAIL
                          extra:
                              pattern: *pattern_email
                        --force:
                            help: Ignore warnings about special groups
                            action: store_true
                remove-mailalias:
                    action_help: Remove mail aliases to group
                    api: DELETE /users/groups/<groupname>/aliases/<aliases>
                    arguments:
                        groupname:
                            help: Name of the group to add user(s) to
                            extra:
                                pattern: *pattern_groupname
                        aliases:
                          help: Mail aliases to remove
                          nargs: "+"
                          metavar: MAIL
                        --force:
                            help: Ignore warnings about special groups
                            action: store_true

Wouhou, it worked ! :partying_face:

Thanks a lot @tituspijean !

1 Like

Issue to follow: Allow to force-adding aliases for special groups by tituspijean · Pull Request #1850 · YunoHost/yunohost · GitHub

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.