Mail on main domain, yunohost on subdomain

, ,

Hi there,

I have a question to get yunohost running.
I’m hosting a fairly big nextcloud instance on my homeserver. which has its own domain (ex.

I would love to use yunohost, to manage mails on and access the nextcloud on

Right now yunohost runs on a vps and should be accessible under
Can I achieve to manage mails through yunohost under

I searched the forum and haven’t found a solution yet.

Best regards!

1 Like


If I understand your problem well, I think I found a solution. If your main domain is registered in yunohost domains (in the administration), then you can edit an user in the administration and chose the correct domain when defining his email address, you can also edit all the aliases. You may have to tweak your DNS configuration a bit so that mails work on main domain (I used the generated DNS config in the “Domains” menu in the admin).

Hope that will solve your problem, if not I’m afraid I can’t be of any help :confused:

1 Like


Thanks for your reply - I already consiedered this thread dead :slight_smile:

Just to be sure, to understand you the right way, I would

  1. Add my domain to the domains
  2. Only add the DNS entries for mail and preserve the rest, so that the nextcloud remains functional
  3. Add user(s) that have mail on the main domain

Thank you very much for your help!


it worked, like you said.

For reference i try to describe my setup in some detail:


  • Yunohost runs under, the DNS is set up according to the generated DNS config by Yunohost
  • The domain was added as well, but only the DNS entries corresponding to mail were added.
    Additionally the mx entry for points to 10

Mail with wildcard aliases

  • The users get wildcard aliases to their primary mail in the form of * this is achieved by a post-user-create-hook which adds the wildcard to the postfix config.
  • Postfix should recognize these aliases, therefore /etc/postfix/ needs to be altered, to preserve this change upon upgrades I created a conf-regen-hook. After upgrade one should execute sudo yunohost conf-regen postfix --force then the updated config can take place with the reference to the regex-aliases.
  • Reference: Mail alias with wildcard - #4 by Martin




# Check if everything is in place
[[ $action == "pre" ]] || exit 0
[[ -e $postfix_conf ]] || exit 0

# Include Regex Aliases
awk -i inplace '{if (/^virtual_alias_maps = /) {$0=$0 ",regexp:/etc/postfix/aliases-regexp"}; print}' $postfix_conf

# Comment out sender mismatch verification
# To send mails from *
sed -e '/reject_sender_login_mismatch/ s/^#*/#/' -i $postfix_conf



echo "/.*$YNH_USER_USERNAME@example\.com/ $YNH_USER_MAIL" | cat - /etc/postfix/aliases-regexp > temp && mv temp /etc/postfix/aliases-regexp

postmap /etc/postfix/aliases-regexp
systemctl restart postfix

After all, I’m no expert in all of this, so if you find errors or wildly exotic handling of configs, I’m more than happy if you tell me.
Best regards

1 Like