Home > Computers > mail > How to create a new mailbox by hand ? | About

What parts are involved

- Postfix is the mail server : it's the software that receives and sends mail. It is not involved.
- mysql : if you have a virtual mapping on mysql then you'll have to create the mailbox in the database.
- cyrus-saslauth : this is the software that checks the email/password combination against the database. It is invovled, but you don't have to touch anything.
- courier-imap : this is the software that talks IMAP and allows mail clients like roundcube to fetch mails for their users. If you're using courier then you'll have to create a MailDir hierarchy using its tools.

Steps to perform for this configuration

  1. Create the user in the database
  2. Create the maildir structure
  3. Create the mailfilter structure
  4. Test that you can authenticate

1) Create the user inside the database

In this example, the authentication is done by saslauthd (cyrus) configured to use mysql. Here is what the configuration file says :

root@messagerie-prod[] /var/vmail/algerian-radio.dz # cat /etc/postfix/sasl/smtpd.conf
pwcheck_method: saslauthd
mech_list: plain login
allow_plaintext: true
auxprop_plugin: mysql
sql_user: user
sql_passwd: password
sql_database: dbispconfig
sql_select: select password from mail_user where (login = '%u' or email = '%u@%r') and postfix = 'y' and disablesmtp = 'n'
root@messagerie-prod[] /var/vmail/algerian-radio.dz # 

In this example, ispconfig is used and the table is dbispconfig.mail_user. Your milage may vary.

INSERT INTO mail_user 
(server_id,email,name,login,password,homedir,maildir,sys_userid, sys_groupid, sys_perm_user, sys_perm_group,quota) 
values (1,'ali.mellah@XXX','ALI MELLAH','ali.mellah@XXX',encrypt('password','$1$Yz8i2YC4'), 
  1. Use the same server_id as the other users (just do a query)
  2. use the email address for both email and login
  3. use the mysql encrypt function to store crypted passwords
  4. use a different salt for each user's password (change encrypt's second argument)
  5. you must set maildir and homedir or the user won't be able to login
  6. you must set sys_* columns or some features won't work (like mail filters), just put the same as the other users you already have (do a query)
  7. you must set the quota value to not run into the quotaerrorvalue

2) Create the mailbox and the maildir structure in the virtual mail directory

You can't test yet if the email/password combination works or not. You have to create the necessary files and folder to make the authentication process work fine.

In this example, courier is used to provied IMAP support for the webmail client (roundcube). The mailbox is created with the maildirmake.courrier command :

maildirmake.courrier /var/vmail/XXX/ali.mellah
chown -R vmail:vmail /var/vmail/XXX/ali.mellah

3) If the mailfilter directory is in another place, don't forget to create a dir there too

mkdir /var/vmail/mailfilters/XXX/ali.mellah

Otherwise, user won't be able to create filters.

4) Make sure postfix is aware of your new mailbox

postmap -q ali.mellah@xxx mysql:/etc/postfix/mysql_virtual_mailboxes.cf

YMMV, maybe the configuration file is different in your case. In any case, you can find the exact file from postfix main.cf configuration file (/etc/postfix/main.cf), at the virtual_mailbox_maps stanza.

5) Test that you can authenticate

authtest email passwd

6) If you want to change the password from the command line (does the necessary queries in MySQL)

authtest email oldpasswd newpasswd

If you don't have the oldpasswd then you can update the password with a mysql query (see step1)

contact : @ychaouche yacinechaouche at yahoocom

QR Code
QR Code What parts are involved (generated for current page)