Mail server - vmail user and mailboxes

Following from the previous article where we looked at setting up the Slice, we can move onto an important aspect of creating a mail server: configuring where the mail will be physically located on the Slice.

The easiest way is to create a 'vmail' user and assign specific IDs to that user.


Vmail user and group

Using the name 'vmail' is a common way of identifying the system user where the mail is physically located.

Note that when we use MySQl for our multiple domains and users, it does not hold the mail itself, just the details of all our users and domains.

The user is created like any other but we will specifically define the vmail group and user IDs and ensure the user cannot login (the vmail user is not one that will have login access to the Slice - it is simply somewhere central to hold the emails.).

Let's start with the vmail group:

sudo groupadd -g 5000 vmail

That creates the group and assigns the GID (group ID) of 5000

Now we can move into the vmail user:

sudo useradd -s /usr/sbin/nologin -g vmail -u 5000 vmail -d /home/vmail -m

This command creates the 'vmail' user, ensures they can't login (it is not a normal account), adds them to the 'vmail' group and creates the home directory.

Summary

Although a short article, setting the 'vmail' user and group with specific IDs is an essential part of the mail server setup.

Missing this section will mean your mail server will not work.

The next article in the series looks at installing Postfix and Mysql.

PickledOnion

Article Comments:

Jeremiah commented Wed Oct 29 16:54:35 UTC 2008:

Just thought I'd let you know that you're missing the final "vmail" on the end of the useradd command.

PickledOnion commented Wed Oct 29 17:25:21 UTC 2008:

Jeremiah,

Although I don't disagree with you - what is the objective of another 'vmail' in the command? The user is created and, as usual, on Ubuntu distros, is in the same group as the user name, in this case 'vmail'.

Could you clarify what adding it does?

PickledOnion

Jeremiah commented Sun Nov 02 03:15:17 UTC 2008:

The command needs it to run? At least it does on my slice, and the man page for useradd says useradd [options] LOGIN

Actually, scratch that - I just tried it with a different user, and it created it as would be expected. I don't know why, but the first time I came through this, it wouldn't create the user unless I added the extra vmail on the end of the command. I must have fudged something earlier, or run into some odd bug.

shane commented Mon Jan 12 17:18:39 UTC 2009:

I changed the order a bit and used: sudo useradd -s /usr/sbin/nologin -g vmail -u 5000 -d /home/vmail -m vmail

Abed commented Mon Jan 19 00:33:26 UTC 2009:

Running this gave me a "Usage: useradd [options] LOGIN". I checked groups/users and didnt see any sign of vmail? Read the comments and simply hit up, appended " vmail" and I'm hoping that did the trick. (Still no sign of vmail when i do groups or users, i guess i'm not supposed to see it?) I dunno, maybe it worked the first time? I assumed because instructions were returned that it didn't work.

Scott commented Tue Mar 03 01:19:20 UTC 2009:

The problem that's tripping people up is that the useradd command in the article has its arguments out of order. As the error message says, the command should be useradd, then options, then login name. In the article, the login name (vmail) is buried in the middle of the options.

Shane has the correct order: "vmail" should be moved to the end of the command.

George commented Fri Mar 13 21:25:23 UTC 2009:

Actually the vmail appearing after the -g flag is used to specify which group to add the user to, i.e. vmail.

sudo useradd -s /usr/sbin/nologin -g vmail -u 5000 -d /home/vmail -m vmail

Would be the proper command. The -m flag is used to specify that you wish the home directory to be created. The command does require a LOGIN however.

Usage: useradd [options] LOGIN

LOGIN in this case should be "vmail"

Jeff Schwab commented Thu Apr 09 22:20:09 UTC 2009:

The command worked for me, exactly as pickled, on Debian Lenny.

David Yell commented Thu Jun 18 14:48:41 UTC 2009:

I also couldn't add the user, I ended up with the following..

sudo useradd -d /home/vmail -g vmail -m vmail -s /sbin/nologin -u 5000

Fred Cord commented Tue Aug 30 01:53:06 UTC 2011:

I have installed Ubuntu on my Vmachine and these articles have been of great help. Sometimes, the order has to be changed within the command in order to get the desired affect.

Want to comment?


(not made public)

(optional)

(use plain text or Markdown syntax)