Postfix to use @ symbol for existing accounts?

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

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 user@example.com 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
andreychek

Howdy,

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.

-Eric

Tue, 09/28/2010 - 13:19
velvetpixel

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

Tue, 09/28/2010 - 13:29
andreychek

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.

-Eric

Tue, 09/28/2010 - 13:35
velvetpixel

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
velvetpixel

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.com user1.example

New account structure: user2@example.com user2-example.com

Edited old account structure: user3@example.com user3/@example.com

Edited new account structure: user4@example.com user4-example.com

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
velvetpixel

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

Tue, 09/28/2010 - 14:44
andreychek

Howdy,

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:

http://www.virtualmin.com/documentation/developer/cli

Tue, 09/28/2010 - 15:00
velvetpixel

Thanks Eric!

Tue, 09/28/2010 - 16:32
velvetpixel

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
andreychek

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.

-Eric

Tue, 09/28/2010 - 17:31
velvetpixel

I had figured out the format:

virtualmin modify-user --domain example.com --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 example.com --user username --newuser username1

virtualmin modify-user --domain example.com --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\@example.com

Like this in /etc/postfix/virtual username@example.com username\@example.com

Tue, 09/28/2010 - 17:34
velvetpixel

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

username@example.com username-example.com

and all mail services work fine for them

but accounts where the username is changed are in this format

username@example.com username\@example.com

and they don't work?

Wed, 09/29/2010 - 08:10
velvetpixel

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 example.com --user changeme --newuser changeme1; virtualmin modify-user --domain example.com --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@example.com user\@example.com

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

How do I fix this????

Wed, 09/29/2010 - 08:39
velvetpixel

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

it enters: user@example.com user\@example.com

It should enter user@example.com user-example.com

Tue, 09/13/2011 - 15:51
Iainad

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?

Thanks

..Iain

Topic locked