# Mail alias with wildcard

**URL:** https://forum.yunohost.org/t/mail-alias-with-wildcard/5820
**Category:** Support
**Tags:** mail, english
**Created:** [September 22, 2018, 10:07am UTC](https://forum.yunohost.org/t/mail-alias-with-wildcard/5820 "2018-09-22T10:07:57Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![DifficularNoblems](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@DifficularNoblems](https://forum.yunohost.org/u/DifficularNoblems)
#### Post date: [September 22, 2018, 10:07am UTC](https://forum.yunohost.org/t/mail-alias-with-wildcard/5820/1 "2018-09-22T10:07:57Z")

</div>

### 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](mailto: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](mailto: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!

---

<div class="post-metadata">

### Author: ![srhodes](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/s/76d3ee/32.png) [@srhodes](https://forum.yunohost.org/u/srhodes)
#### Post date: [September 25, 2018, 7:31pm UTC](https://forum.yunohost.org/t/mail-alias-with-wildcard/5820/2 "2018-09-25T19:31:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ClothesFree](https://forum.yunohost.org/user_avatar/forum.yunohost.org/clothesfree/32/1626_2.png) [@ClothesFree](https://forum.yunohost.org/u/ClothesFree)
#### Post date: [October 17, 2018, 11:03pm UTC](https://forum.yunohost.org/t/mail-alias-with-wildcard/5820/3 "2018-10-17T23:03:04Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![Martin](https://forum.yunohost.org/user_avatar/forum.yunohost.org/martin/32/4211_2.png) [@Martin](https://forum.yunohost.org/u/Martin)
#### Post date: [December 8, 2020, 3:35pm UTC](https://forum.yunohost.org/t/mail-alias-with-wildcard/5820/4 "2020-12-08T15:35:58Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ljf](https://forum.yunohost.org/user_avatar/forum.yunohost.org/ljf/32/58_2.png) [@ljf](https://forum.yunohost.org/u/ljf)
#### Post date: [December 8, 2020, 5:44pm UTC](https://forum.yunohost.org/t/mail-alias-with-wildcard/5820/5 "2020-12-08T17:44:21Z")

</div>

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:

```auto
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:

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

```

Use postmap on it

```auto
postmap /etc/postfix/aliases-regexp

```

Define in yunohost admin an alias [mailbox@example.com](mailto:mailbox@example.com) on a user.

Restart postfix

```auto
systemctl restart postfix

```

---

<div class="post-metadata">

### Author: ![Martin](https://forum.yunohost.org/user_avatar/forum.yunohost.org/martin/32/4211_2.png) [@Martin](https://forum.yunohost.org/u/Martin)
#### Post date: [April 13, 2021, 4:31pm UTC](https://forum.yunohost.org/t/mail-alias-with-wildcard/5820/6 "2021-04-13T16:31:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![samuel-ynh](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@samuel-ynh](https://forum.yunohost.org/u/samuel-ynh)
#### Post date: [November 22, 2022, 3:52pm UTC](https://forum.yunohost.org/t/mail-alias-with-wildcard/5820/7 "2022-11-22T15:52:07Z")

</div>

This worked! ([Mail on main domain, yunohost on subdomain - #3 by samuel-ynh](https://forum.yunohost.org/t/mail-on-main-domain-yunohost-on-subdomain/21935/3))

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!

---

<div class="post-metadata">

### Author: ![Martin](https://forum.yunohost.org/user_avatar/forum.yunohost.org/martin/32/4211_2.png) [@Martin](https://forum.yunohost.org/u/Martin)
#### Post date: [January 15, 2024, 9:33pm UTC](https://forum.yunohost.org/t/mail-alias-with-wildcard/5820/8 "2024-01-15T21:33:45Z")

</div>

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](http://www.postfix.org/regexp_table.5.html)  
[https://www.postfix.org/virtual.5.html](https://www.postfix.org/virtual.5.html)  
[https://www.postfix.org/regexp\_table.5.html](https://www.postfix.org/regexp_table.5.html)

---

<div class="post-metadata">

### Author: ![Martin](https://forum.yunohost.org/user_avatar/forum.yunohost.org/martin/32/4211_2.png) [@Martin](https://forum.yunohost.org/u/Martin)
#### Post date: [January 15, 2024, 9:50pm UTC](https://forum.yunohost.org/t/mail-alias-with-wildcard/5820/9 "2024-01-15T21:50:03Z")

</div>

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

```auto
# Requirements for the sender address
smtpd_sender_restrictions =
# reject_sender_login_mismatch,

```

This maybe a security choice.

---

<div class="post-metadata">

### Author: ![Aleks](https://forum.yunohost.org/user_avatar/forum.yunohost.org/aleks/32/1704_2.png) [@Aleks](https://forum.yunohost.org/u/Aleks)
#### Post date: [January 15, 2024, 10:58pm UTC](https://forum.yunohost.org/t/mail-alias-with-wildcard/5820/10 "2024-01-15T22:58:30Z")

</div>

> [@Martin](#):
>
> 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” 😅

---

<div class="post-metadata">

### Author: ![Martin](https://forum.yunohost.org/user_avatar/forum.yunohost.org/martin/32/4211_2.png) [@Martin](https://forum.yunohost.org/u/Martin)
#### Post date: [January 16, 2024, 8:13am UTC](https://forum.yunohost.org/t/mail-alias-with-wildcard/5820/11 "2024-01-16T08:13:45Z")

</div>

another useful link for postfix regex : [postfix\_virtual\_mail\_addresses\_with\_regular\_expressions [pswiki]](https://wiki.psuter.ch/doku.php?id=postfix_virtual_mail_addresses_with_regular_expressions)

* * *

@Aleks🤣
