Unifix knowledge database - The original one

Dashboard - News - Search - List - About - Admin


Installing mailserver on Debian

Author:black - Tue Nov 27 01:57:24 2007

### Install packages needed:
apt-get install apache2 mysql-server libapache2-mod-php5 php5-mysql postfix postfix-mysql courier-authlib-mysql courier-imap courier-pop

### Answers:
Create Web Based Configuration: NO
General type of configuration: Internet Site
Mail name: mail02.ar.mcn.dk

### Run this to edit /etc/postfix/main.cf:

postconf -e myhostname=mail02.ar.mcn.dk
postconf -e mydomain=mcn.dk
postconf -e mynetworks=127.0.0.0/8
postconf -e alias_maps=mysql:/etc/postfix/mysql-aliases.cf
postconf -e relocated_maps=mysql:/etc/postfix/mysql-relocated.cf
postconf -e local_transport=local
postconf -e 'local_recipient_maps=$alias_maps $virtual_mailbox_maps unix:passwd.byname'
postconf -e virtual_transport=virtual
postconf -e virtual_mailbox_domains=mysql:/etc/postfix/mysql-transport.cf
postconf -e virtual_minimum_uid=1000
postconf -e virtual_gid_maps=mysql:/etc/postfix/mysql-virtual-gid.cf
postconf -e virtual_mailbox_maps=mysql:/etc/postfix/mysql-virtual-maps.cf
postconf -e virtual_alias_maps=mysql:/etc/postfix/mysql-virtual.cf
postconf -e virtual_uid_maps=mysql:/etc/postfix/mysql-virtual-uid.cf
postconf -e virtual_mailbox_base=/

### file mysql-aliases.cf:
# mysql-aliases.cf

user         = mailsql
password     = mypassword
dbname       = mailsql
table        = alias
select_field = destination
where_field  = alias
hosts        = 127.0.0.1

### file mysql-relocated.cf:
# mysql-relocated.cf

user         = mailsql
password     = mypassword
dbname       = mailsql
table        = relocated
select_field = destination
where_field  = email
hosts        = 127.0.0.1

### file mysql-transport.cf:
# mysql-transport.cf

user         = mailsql
password     = mypassword
dbname       = mailsql
table        = transport
select_field = destination
where_field  = domain
hosts        = 127.0.0.1

### file mysql-virtual-gid.cf:
#myql-virtual-gid.cf

user                  = mailsql
password              = mypassword
dbname                = mailsql
table                 = users
select_field          = gid
where_field           = email
additional_conditions = and postfix = 'y'
hosts                 = 127.0.0.1

### file mysql-virtual-maps.cf:
#myql-virtual-maps.cf

user                  = mailsql
password              = mypassword
dbname                = mailsql
table                 = users
select_field          = maildir
where_field           = email
additional_conditions = and postfix = 'y'
hosts                 = 127.0.0.1

### file mysql-virtual-uid.cf:
# mysql-virtual-uid.cf

user                  = mailsql
password              = mypassword
dbname                = mailsql
table                 = users
select_field          = uid
where_field           = email
additional_conditions = and postfix = 'y'
hosts                 = 127.0.0.1

### file mysql-virtual.cf:
# mysql-virtual.cf

user         = mailsql
password     = mypassword
dbname       = mailsql
table        = virtual
select_field = destination
where_field  = email
hosts        = 127.0.0.1

### file mailsql.sql:
-- phpMyAdmin SQL Dump
-- version 2.11.1.2
-- http://www.phpmyadmin.net
--
-- Vært: localhost
-- Genereringstid: 26. 11 2007 kl. 21:44:15
-- Serverversion: 5.0.44
-- PHP-version: 5.2.4_p20070914-pl2-gentoo

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `mailsql`
--

-- --------------------------------------------------------

--
-- Struktur-dump for tabellen `alias`
--

CREATE TABLE IF NOT EXISTS `alias` (
  `id` int(11) NOT NULL auto_increment,
  `alias` varchar(42) NOT NULL default '',
  `destination` varchar(42) NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

-- --------------------------------------------------------

--
-- Struktur-dump for tabellen `relocated`
--

CREATE TABLE IF NOT EXISTS `relocated` (
  `id` int(11) NOT NULL auto_increment,
  `email` varchar(42) NOT NULL default '',
  `destination` varchar(42) NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;

-- --------------------------------------------------------

--
-- Struktur-dump for tabellen `transport`
--

CREATE TABLE IF NOT EXISTS `transport` (
  `id` int(11) NOT NULL auto_increment,
  `domain` varchar(42) NOT NULL default '',
  `destination` varchar(42) NOT NULL default '',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `domain` (`domain`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

-- --------------------------------------------------------

--
-- Struktur-dump for tabellen `users`
--

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL auto_increment,
  `email` varchar(42) NOT NULL default '',
  `clear` varchar(42) NOT NULL default '',
  `name` tinytext NOT NULL,
  `uid` int(11) NOT NULL default '1101',
  `gid` int(11) NOT NULL default '1101',
  `homedir` tinytext NOT NULL,
  `maildir` tinytext NOT NULL,
  `quota` tinytext NOT NULL,
  `postfix` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8  ;

-- --------------------------------------------------------

--
-- Struktur-dump for tabellen `virtual`
--

CREATE TABLE IF NOT EXISTS `virtual` (
  `id` int(11) NOT NULL auto_increment,
  `email` varchar(42) NOT NULL default '',
  `destination` varchar(42) NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

### edit /etc/courier/authdaemonrc:

authmodulelist="authmysql"


### file /etc/courier/authmysqlrc:
MYSQL_SERVER            127.0.0.1
MYSQL_USERNAME          mailsql
MYSQL_PASSWORD          mypassword
MYSQL_DATABASE          mailsql
#MYSQL_CRYPT_PWFIELD    crypt
MYSQL_USER_TABLE        users
MYSQL_CLEAR_PWFIELD     clear
MYSQL_LOGIN_FIELD       email
MYSQL_HOME_FIELD        homedir

### After creating the files run:
groupadd -g 1101 vmail
useradd -u 1101 -g 1101 -d /var/vmail -m vmail
mysqladmin create mailsql
mysql mailsql < mailsql.sql
echo "grant all privileges on mailsql.* to mailsql@localhost identified by 'pass1234';" | mysql
sed -i -e 's/mypassword/pass1234/' /etc/postfix/mysql-* /etc/courier/authmysqlrc
/etc/init.d/postfix reload
/etc/init.d/courier-authdaemon restart
/etc/init.d/courier-imap restart
/etc/init.d/courier-pop restart
Copyright(c) Unifix.org 2002-2011


Dashboard - News - Search - List - About - Admin
 
Powered by Mikjaer Consulting Solutions - Hosted by Specialhosting.dk