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`)
VALUES
  ('1', 'example.com'),
  ('2', 'hostname.example.com'),
  ('3', 'hostname'),
  ('4', 'localhost.example.com');

Adding Email Accounts:

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

Adding Aliases for Email Accounts:

INSERT INTO `mailserver`.`virtual_aliases`
  (`id`, `domain_id`, `source`, `destination`)
VALUES
  ('1', '1', 'alias@example.com', 'email1@example.com');

From this setup tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *