Mail alias with wildcard

My YunoHost configuration

Hardware: x64 vps
Internet access: in a datacenter
**YunoHost version: **
yunohost: 3.2.1
yunohost-admin: 3.2.1
moulinette: 3.2.0
ssowat: 3.2.0
Have you personalized your yunohost with some specifics configurations or do you use only the yunohost cli/webadmin tool ? basic

Description of my problem

Hello all,

I would like to add a mail alias with a wildcard to an account, so that it receives all mail in the form “mailboxUNIQUECODE@example.com”. I tried adding a mail alias in the form “mailbox*@example.com” but I get the error “Error: Invalid argument ‘add_mailalias’: Must be a valid email address (e.g. someone@domain.org)”

Is there a way to setup such a system? I would also be able to work with a catch-all mailbox, which receives all the messages sent to the server.

Thanks to everyone!

1 Like

I, too, would like to know whether wildcard or catch-all email addressing is doable. Thank you!

I tried to create an alias *@demo.yunohost.org on the demo site, but it’s rejected

Would be great if there’s official support of wildcard email alias, thanks!

1 Like

Hello,
Yes it will be a good feature for me too. :grinning:
Is there another way to do this ?
Thanks

For the moment, only the + selector support is available.

SO email+XXXXX@domain.tld

BUT you can do it “by hand” and with cli, you need to change /etc/postfix/main.cf with:

virtual_alias_maps = hash:/var/lib/mailman/data/virtual-mailman,ldap:/etc/postfix/ldap-aliases.cf,regexp:/etc/postfix/aliases-regexp

Create a file /etc/postfix/aliases-regexp like this one:

/mailbox.*@example\.com/ mailbox@example.com

Use postmap on it

postmap /etc/postfix/aliases-regexp

Define in yunohost admin an alias mailbox@example.com on a user.

Restart postfix

systemctl restart postfix
2 Likes

Thank @ljf I will try it :smiley:
(I didn’t see before you made an answer !!)

This worked! (Mail on main domain, yunohost on subdomain - #3 by samuel-ynh)

But unfortunately only for receiving mails, if I try to send a mail from a wildcard alias I get:
Sender address rejected: not owned by user

Do you have an idea on how to send mails from wildcard aliases?

Thanks in advance!

J’ai eu quelques erreurs de correspondances des regex. J’ai compris qu’il faut bien borner la règle.
Exemple :
/mailbox.*@example\.com/ mailbox@example.com
va correspondre Ă  : mailboxdetoto@example.com
mais aussi Ă  : toto.mailbox1@example.com
Si on ne veut pas alors il faut plutĂ´t ĂŠcrire /^mailbox.*@example\.com/ mailbox@example.com

Quelques liens utiles ĂŠgalement :
http://www.postfix.org/regexp_table.5.html
https://www.postfix.org/virtual.5.html
https://www.postfix.org/regexp_table.5.html

Hello, to make it working I commented the line : reject_sender_login_mismatch, in the /etc/postfix/main.cf

# Requirements for the sender address
smtpd_sender_restrictions =
# reject_sender_login_mismatch,

This maybe a security choice.

Apriori this means that anybody can send an email using anybody’s identity so yeah … “Couldn’t figure out what’s wrong with the keys, so we removed the lock and now anybody can enter the house, problem solved” :sweat_smile:

2 Likes

another useful link for postfix regex : postfix_virtual_mail_addresses_with_regular_expressions [pswiki]


@Aleks :rofl: