Notepad:Postfix: Difference between revisions

From Amar
Jump to navigationJump to search
No edit summary
Line 34: Line 34:


= Config Files =
= Config Files =
vi /etc/postfix/mysql-virtual_domains.cf
* /etc/postfix/mysql-virtual_domains.cf


  user = mail_admin
  user = mail_admin
Line 42: Line 42:
  hosts = 127.0.0.1
  hosts = 127.0.0.1


vi /etc/postfix/mysql-virtual_forwardings.cf
* /etc/postfix/mysql-virtual_forwardings.cf


  user = mail_admin
  user = mail_admin
Line 50: Line 50:
  hosts = 127.0.0.1
  hosts = 127.0.0.1


vi /etc/postfix/mysql-virtual_mailboxes.cf
* /etc/postfix/mysql-virtual_mailboxes.cf


  user = mail_admin
  user = mail_admin
Line 58: Line 58:
  hosts = 127.0.0.1
  hosts = 127.0.0.1


vi /etc/postfix/mysql-virtual_email2email.cf
* /etc/postfix/mysql-virtual_email2email.cf


  user = mail_admin
  user = mail_admin
Line 66: Line 66:
  hosts = 127.0.0.1
  hosts = 127.0.0.1


vi /etc/postfix/mysql-virtual_transports.cf
* /etc/postfix/mysql-virtual_transports.cf


  user = mail_admin
  user = mail_admin
Line 74: Line 74:
  hosts = 127.0.0.1
  hosts = 127.0.0.1


vi /etc/postfix/mysql-virtual_mailbox_limit_maps.cf
* /etc/postfix/mysql-virtual_mailbox_limit_maps.cf


  user = mail_admin
  user = mail_admin

Revision as of 18:15, 27 April 2015

MySQL Postfix

GRANT SELECT, INSERT, UPDATE, DELETE ON mail.* TO 'mail_admin'@'localhost' IDENTIFIED BY 'mail_admin_password';
GRANT SELECT, INSERT, UPDATE, DELETE ON mail.* TO 'mail_admin'@'localhost.localdomain' IDENTIFIED BY 'mail_admin_password';
FLUSH PRIVILEGES;

Still on the MySQL shell, we create the tables needed by Postfix and Courier:

USE mail;

CREATE TABLE domains (
domain varchar(50) NOT NULL,
PRIMARY KEY (domain) )
ENGINE=MyISAM;

CREATE TABLE forwardings (
source varchar(80) NOT NULL,
destination TEXT NOT NULL,
PRIMARY KEY (source) )
ENGINE=MyISAM;

CREATE TABLE users (
email varchar(80) NOT NULL,
password varchar(20) NOT NULL,
quota INT(10) DEFAULT '10485760',
PRIMARY KEY (email)
) ENGINE=MyISAM; 

CREATE TABLE transport (
domain varchar(128) NOT NULL default ,
transport varchar(128) NOT NULL default ,
UNIQUE KEY domain (domain)
) ENGINE=MyISAM;

Config Files

  • /etc/postfix/mysql-virtual_domains.cf
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT domain AS virtual FROM domains WHERE domain='%s'
hosts = 127.0.0.1
  • /etc/postfix/mysql-virtual_forwardings.cf
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT destination FROM forwardings WHERE source='%s'
hosts = 127.0.0.1
  • /etc/postfix/mysql-virtual_mailboxes.cf
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') FROM users WHERE email='%s'
hosts = 127.0.0.1
  • /etc/postfix/mysql-virtual_email2email.cf
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT email FROM users WHERE email='%s'
hosts = 127.0.0.1
  • /etc/postfix/mysql-virtual_transports.cf
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT transport FROM transport WHERE domain='%s'
hosts = 127.0.0.1
  • /etc/postfix/mysql-virtual_mailbox_limit_maps.cf
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT quota FROM users WHERE email='%s'
hosts = 127.0.0.1

Then change the permissions and the group of these files:

chmod o= /etc/postfix/mysql-virtual_*.cf
chgrp postfix /etc/postfix/mysql-virtual_*.cf

Now we create a user and group called vmail with the home directory /home/vmail. This is where all mail boxes will be stored.

groupadd -g 5000 vmail
useradd -g vmail -u 5000 vmail -d /home/vmail -m