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 ffa_mailserver;
  • CREATE USER 'mailuser'@'127.0.0.1' IDENTIFIED BY 'password';
  • GRANT SELECT ON ffa_mailserver.* TO 'mailuser'@'127.0.0.1';
  • FLUSH PRIVILEGES;
Crear Taules
  • USE ffa_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

  • sudo nano /etc/postfix/mysql-virtual-mailbox-domains.cf
    • Virtualdomain.png
  • sudo nano /etc/postfix/mysql-virtual-mailbox-maps.cf
    • Virtualuser .png
  • sudo nano /etc/postfix/mysql-virtual-alias-maps.cf
    • Virtualalias.png
  • sudo nano /etc/postfix/mysql-virtual-email2email.cf
    • Email2email.png
  • sudo service postfix restart
  • Fem la prova de configuració
    • postmap -q mydomain1.com mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
    • postmap -q email1@mydomain1.com mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
    • postmap -q mydomain1.com mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
    • postmap -q alias@mydomain1.com mysql:/etc/postfix/mysql-virtual-alias-maps.cf
    • postmap -q alias@mydomain1.com mysql:/etc/postfix/mysql-virtual-email2email.cf

Dovecot

Roundcube