I have a few recently migrated domains with over 200 mail accounts and need to modify Postfix to allow clients to connect using user@example.com format rather than user.account.
Where can I change this for the domain or the whole system with Virtualmin or Webmin?
Whenever a new email account is created, the format used for that account is set in System Settings -> Server Templates -> Default -> Mail for Domain.
To use the user@domain format, look at the bottom of that screen for an option named “Format for usernames that include domain”, which you can change that to user@domain.
Well, changing the names of users after they’re created is a lot more complex
You can do it, but it requires custom scripting using the command line tools.
If you run “virtualmin modify-user” from the command line, you’ll see a list of options there.
You should be able to use the --newuser option to change the username to your preferred format.
What you’d need to do is loop through all the Virtual Servers on your system (which you can do with “virtualmin list-domains”, and then loop through each account in those domains (with “virtualmin list-users --domain DOMAIN_NAME”), and use the --newuser option to change the accounts.
Of course, I’d recommend testing that on one account first before you run that against all of them.
If you’re able to remove them all and start over, that may be a simpler solution, as all you’d need to do is update the email format setting in the server templates before performing the migration.
It’s a pain due to the fact the mail accounts have been migrated and the clients are not able to connect due to the different connection style (account name format) and having all those people change their mail clients is not an option.
With the template changed to @ if I add a new mail account everything works great.
If I change and change back the name of an existing account to let it take on the @ style it fails and it looks like it is due to the entry in /etc/postfix virtual being strange.
You said to use --newuser but is that just for making a new account? How does that relate to my need to modify an account? I just tried to use the virtualmin modify-user --username username to try to have the script change the users name to itselft to update to the new @ and it’s not doing anything.
When using “modify-user”, the --user parameter states which user you’re updating. The --newuser parameter is where you’d specify what the new username should be. Except that in your case, the --user and --newuser would be the same… that should get it to regenerate the usernames and to put them into the user@domain format.
It works and the smtp connection starts working from the client but then the imap connection fails so the user cannot receive. I see that doing the above creates an alias for the user even though there is an actual mail user. Why is it doing this and is this normal?
Ok now I am stuck and in TROUBLE due to the virtualmin CLI --newuser command.
When changing a working account that is in this format username.account it makes the account no longer functional with User unknown in virtual alias table errors when attempting to send to this account.
When I do the change I do it twice. first away from user to a temporary user1 and then back to user. Like this:
OK I Found the issue and it looks like it is a bug in Virtualmin!
using the --newuser command fails to do two things to make the changed account a functional email account when switching from user.account postfix style to user@example.com style.
It doesn’t add a user-domain style user to /etc/passwd
It doesn’t correctly then enter the alias in /etc/postfix/virtual
I’m trying to do exactly this as I inadvertently didn’t set the template correctly when migrating a few Plesk virtual domains.
I have a user iain.domain that I want to change to iain@domain.com. From the posts above it’s clear I need to change the user to an intermediate one and then back if I want to keep the same name.
When I create a new user from the CLI all is fine it’s in the user@domain.com format
When I use the CLI
e.g. virtualmin modify-user --domain domain.com --user iain --newuser iain2
it creates the new user as iain2.domain if the use was one that was created before hand. I know I could delete the user and create a new one but they all have existing mailboxes etc.
Anyone got any idea how to actually manage to do this?