Servidor Correu

De FFAWiki

Postfix, Mysql, Dovecot i Roundcube

Preparació

  • Crear un registres MX
    • MX.png
  • Afegir a el domini a /etc/hosts
    • Etc hosts.png

Instal·lació

  • sudo apt-get install postfix postfix-mysql dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql roundcube roundcube-core
    • Install server correu.png
    • Seguir les instruccions

Configuració

Mysql

  • sudo mysql
Crear usuari i BD
  • CREATE DATABASE mailserver;
  • CREATE USER 'mailuser'@'127.0.0.1' IDENTIFIED BY 'password';
  • GRANT SELECT ON mailserver.* TO 'mailuser'@'127.0.0.1';
  • FLUSH PRIVILEGES;
Crear Taules
  • USE mailserver;
Taula dominis virtuals
  • CREATE TABLE `virtual_domains` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Taula correus virtuals
  • CREATE TABLE `virtual_users` (`id` INT NOT NULL AUTO_INCREMENT,`domain_id` INT NOT NULL,`password` VARCHAR(106) NOT NULL,`email` VARCHAR(120) NOT NULL,PRIMARY KEY (`id`),UNIQUE KEY `email` (`email`),FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Taula alias virtuals
  • CREATE TABLE `virtual_aliases` (`id` INT NOT NULL AUTO_INCREMENT,`domain_id` INT NOT NULL,`source` varchar(100) NOT NULL,`destination` varchar(100) NOT NULL, PRIMARY KEY (`id`),FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Emplenar Taules
Taula dominis virtuals
  • INSERT INTO `mailserver`.`virtual_domains` (`id` ,`name`) VALUES ('1', 'mydomain1.com');
Taula correus virtuals
  • INSERT INTO `mailserver`.`virtual_users` (`id`, `domain_id`, `password` , `email`) VALUES ('1', '1', ENCRYPT('mypassword1', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))), 'email1@mydomain1.com');
Taula alias virtuals
  • INSERT INTO `servermail`.`virtual_aliases` (`id`, `domain_id`, `source`, `destination`) VALUES ('1', '1', 'myalias@example.com', 'email1@mydomain1.com');

Postfix

Dovecot

Roundcube