Add a redirection mail/alias without attaching it to a YunoHost account


I recently needed to create an alias who redirect to an email not manage by my yunohost instance.

To do it, I wrote into the LDAP which is read by Postfix (the mail system).
Firstly i created a file with this command

nano aliasmail 

containing the declaration of the “alias” organisational unit, and an entry with it like that

dn: ou=alias,dc=yunohost,dc=org
objectClass: organizationalUnit
objectClass: top
ou: alias

dn: uid=mail1,ou=alias,dc=yunohost,dc=org
uid: mail1
uid: jean
objectClass: inetOrgPerson
objectClass: mailAccount
cn: Jean DUPONT
sn: Jean
maildrop: redirection@anotherdomain.tld

Then I run this command to add these element to the ldap

sudo ldapadd -x -D cn=admin,dc=yunohost,dc=org -W -f aliasmail

And the redirection was done, if I sent a mail to it was resent to redirection@anotherdomain.tld.

Note: if you need a second alias/redirection, you don’t need to put the first part of the file because it is already in the ldap.
Note2: you can redirect an alias to several mail by adding several “maildrop” line.

1 Like

Nice, that could be an idea for an application. I’ve packaged an app like this but it is not compatible with the ldap alias system of yunohost. With this one, you can keep the yunohost alias system.

Nice tip !

On my side what I would appreciate is having one alias that forwards to a number of already registered yunohost users, without creating an additionnal yunohost user specifically for that.
Seems like your solution could fit the purpose.

Definilty, we need to have this feature available within the moulinette !!

I know this topic is very old, but I have the very same need (e-mail forwarding without Yunohost account).
Does anyone know if this is the only/preferred method to address that need?

On the other hand, would it be possible to have a yunohost account, with e-mail forwarding and no local IMAP account?

Thanks !

Which email address do you need forwarded where exactly? And for what purpose?
Because if you just want to use a YunoHost account and read/send emails using another address, you can just use the Rainloop app and add all your addresses.

I’m planning to manage the family domain which corresponds to our last name: every member has a first_name@domain forwarding e-mail address. So ideally:

  • some users would have a yunohost account, but I don’t wan’t to host their e-mails --> only forwarding to their own personal e-mail account ( or whatever)
  • some users wouldn’t have a yunohost account, but still they would need to get the e-mails forwarded to their own personal e-mail account

I rested it today, 2 years after, and it works

1 Like

digging up this subject once again !

Is there any way to do the alias in the yunohost web interface ?
(I’d like it to be understandable for the next person in my organisation who have to manage the aliases)

J’utilise un alias avec cette méthode depuis quelques années, et là il ne marche plus depuis la màj vers 3.7. Une idée de pourquoi ?
L’entrée est bien toujours présente dans le ldap :

admin@serveur:/etc/postfix$ sudo ldapsearch -x -h localhost -b "dc=yunohost,dc=org" "(uid=mail1)"
# extended LDIF
# LDAPv3
# base <dc=yunohost,dc=org> with scope subtree
# filter: (uid=mail1)
# requesting: ALL

# mail1, alias,
dn: uid=mail1,ou=alias,dc=yunohost,dc=org
uid: mail1
uid: jean
objectClass: inetOrgPerson
objectClass: mailAccount
cn: Jean DUPONT
sn: Jean

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

Bon, à priori c’est normal que ça ait sauté, car le système de permission a changé dans 3.7.
En attendant mieux, j’ai supprimé la règle dans le ldap : sudo ldapdelete -x -D cn=admin,dc=yunohost,dc=org -W uid=mail1,ou=alias,dc=yunohost,dc=org , puis j’ai créé un utilisateur et redirigé vers les deux adresses.

The method still works, but you have additional information to add to your alias:

  • add the objectClass userPermissionYnh
  • add the permission attribute with the value cn=mail.main,ou=permission,dc=yunohost,dc=org

Hope it helps!