Syntax for template to automatically create e-mail address for users with only "lastname" and users with "firstname.lastname"

I use templates to create users e-mail addresses, but sometimes they dont have a firstname and this results in an email-address like “.testuser@domain.tld” what would I need to do in my template to only include the dot “.” in the mail-address if there is a firstname?

Hey,

unfortunately this is not possible via the template mechanism and is mentioned in the handbook too:

For example, the UNIX home directory can be stored under /home/<title>.<lastname> or the primary email address can be predefined with <firstname>.<lastname>@company.com. Substitutions are generally possibly for any value, but there is no syntax or semantics check. So, if no first name is specified when creating a user, the above e-mail address would begin with a dot and would thus be invalid according to the e-mail standard.

https://docs.software-univention.de/manual/5.0/en/user-management/user-templates.html

You could extend the user creation/modify via hooks or a listener module to generate the mailadress according to your logic tough.

Best regards
Jan-Luca

1 Like