Okay,
it worked, like you said.
For reference i try to describe my setup in some detail:
Domain
- Yunohost runs under
yunohost.example.com
, the DNS is set up according to the generated DNS config by Yunohost - The domain
example.com
was added as well, but only the DNS entries corresponding to mail were added.
Additionally the mx entry for example.com points to10 yunohost.example.com
Mail with wildcard aliases
- The users get wildcard aliases to their primary mail in the form of
*username@example.com
this is achieved by apost-user-create
-hook which adds the wildcard to the postfix config. - Postfix should recognize these aliases, therefore
/etc/postfix/main.cf
needs to be altered, to preserve this change upon upgrades I created aconf-regen
-hook. After upgrade one should executesudo 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
/etc/yunohost/hooks.d/conf_regen/20-postfix_modifications
#!/bin/bash
action=$1
pending_dir=$4
postfix_conf=$pending_dir/../postfix/etc/postfix/main.cf
# 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 *@mydomain.org
sed -e '/reject_sender_login_mismatch/ s/^#*/#/' -i $postfix_conf
/etc/yunohost/hooks.d/post_user_create/10-new-user-postfix-regex
#!/bin/bash
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
Samuel