Postfix to use @ symbol for existing accounts?

16 posts / 0 new
Last post
#1 Tue, 09/28/2010 - 13:04

Postfix to use @ symbol for existing accounts?

I have a few recently migrated domains with over 200 mail accounts and need to modify Postfix to allow clients to connect using format rather than user.account.

Where can I change this for the domain or the whole system with Virtualmin or Webmin?

Tue, 09/28/2010 - 13:15


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.


Tue, 09/28/2010 - 13:19

How does that change the functionality of the 200+ mail accounts already created using the user,account format?

Tue, 09/28/2010 - 13:29

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.


Tue, 09/28/2010 - 13:35

Thanks for the info Eric!

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.

Tue, 09/28/2010 - 14:33

Ok Finding a little info now.

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.

Old account structure: user1.example

New account structure:

Edited old account structure: user3/

Edited new account structure:

Is this a bug in virtualmin?

If I manually edit the virtual file and update the db to change user3/@ to user3- I still get failures due to user not found when sending to user3@

Any Ideas how I can modify all old manually so that virtualmin and postfix are both happy?

Will the --newuser option change the account differently that doing it through the GUI?

Tue, 09/28/2010 - 14:40

Where can I find instructions on the virtualmin CLI commands, what they do and how to use them?

Tue, 09/28/2010 - 14:44


They're largely self-documenting, actually.

If you run "virtualmin" from the command line, you'll see a list of available options.

Once you find the option that does what you're after, you can then run "virtualmin OPTION_NAME" for more options, and example usage.

If you prefer to view all that using the web though, there's instructions available here:

Tue, 09/28/2010 - 15:00

Thanks Eric!

Tue, 09/28/2010 - 16:32

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.

Tue, 09/28/2010 - 17:06

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.


Tue, 09/28/2010 - 17:31

I had figured out the format:

virtualmin modify-user --domain --user username --newuser username

Has no effect and generates this output: New username is the same as the old

If I change the username and then change it back

virtualmin modify-user --domain --user username --newuser username1

virtualmin modify-user --domain --user username1 --newuser username

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?

Like this virtualmin: username Address username\

Like this in /etc/postfix/virtual username\

Tue, 09/28/2010 - 17:34

Why are names in the virtual file when a new account created in this format:

and all mail services work fine for them

but accounts where the username is changed are in this format username\

and they don't work?

Wed, 09/29/2010 - 08:10

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:

virtualmin modify-user --domain --user changeme --newuser changeme1; virtualmin modify-user --domain --user changeme1 --newuser changeme;

I get successful returns on both commands and the account is able to be accessed through the 20000 webmail interface.

When looking in the virtual file or in the virtualmin virtual domain aliases page I see that the account has an entry like this: user\

Is virtualmin breaking these accounts with a bad virtual alias entry?

How do I fix this????

Wed, 09/29/2010 - 08:39

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 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

it enters: user\

It should enter

Tue, 09/13/2011 - 15:51

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 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 format

When I use the CLI

e.g. virtualmin modify-user --domain --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?



Topic locked