Category Archives: server

Adding Email Accounts to Mail Server

Recently I setup dovecot and postfix to handle email for my multiple domains.  I configured MySQL in order to manage the many accounts I plan to create.  Below is a cheat sheet on how to add domains and accounts.

Adding Virtual Domains to the mail server:

INSERT INTO `mailserver`.`virtual_domains`
  (`id` ,`name`)
  ('1', ''),
  ('2', ''),
  ('3', 'hostname'),
  ('4', '');

Adding Email Accounts:

INSERT INTO `mailserver`.`virtual_users`
  (`id`, `domain_id`, `password` , `email`)
  ('1', '1', ENCRYPT('firstpassword', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))), ''),
  ('2', '1', ENCRYPT('secondpassword', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))), '');

Adding Aliases for Email Accounts:

INSERT INTO `mailserver`.`virtual_aliases`
  (`id`, `domain_id`, `source`, `destination`)
  ('1', '1', '', '');

From this setup tutorial