installation serveur : MAIL (mode local avec redirections)

Retour

doc source : http://flurdy.com/docs/postfix/

apt-get update
apt-get upgrade
install mysql-client mysql-server

créer un user et sa bdd "mail"

créer les tables suivantes :
CREATE TABLE aliases (
pkid smallint(3) NOT NULL auto_increment,
mail varchar(120) NOT NULL default '',
destination varchar(120) NOT NULL default '',
enabled tinyint(1) NOT NULL default '1',
PRIMARY KEY  (pkid),
UNIQUE KEY mail (mail)
) ;
CREATE TABLE domains (
pkid smallint(6) NOT NULL auto_increment,
domain varchar(120) NOT NULL default '',
transport varchar(120) NOT NULL default 'virtual:',
enabled tinyint(1) NOT NULL default '1',
PRIMARY KEY  (pkid)
) ;
CREATE TABLE users (
id varchar(128) NOT NULL default '',
name varchar(128) NOT NULL default '',
uid smallint(5) unsigned NOT NULL default '5000',
gid smallint(5) unsigned NOT NULL default '5000',
home varchar(255) NOT NULL default '/var/spool/mail/virtual',
maildir varchar(255) NOT NULL default 'blah/',
enabled tinyint(3) unsigned NOT NULL default '1',
change_password tinyint(3) unsigned NOT NULL default '1',
clear varchar(128) NOT NULL default 'ChangeMe',
crypt varchar(128) NOT NULL default 'sdtrusfX0Jj66',
quota varchar(255) NOT NULL default '',
procmailrc varchar(128) NOT NULL default '',
spamassassinrc varchar(128) NOT NULL default '',
PRIMARY KEY  (id),
UNIQUE KEY id (id)
) ;

INSERT INTO domains (domain) VALUES
('localhost'),
('localhost.localdomain');
INSERT INTO aliases (mail,destination) VALUES
('postmaster@localhost','root@localhost'),
('sysadmin@localhost','root@localhost'),
('webmaster@localhost','root@localhost'),
('abuse@localhost','root@localhost'),
('root@localhost','root@rafi.piccolo@gmail.com'),
('@localhost','root@localhost'),
('@localhost.localdomain','@localhost');
INSERT INTO users (id,name,maildir,crypt) VALUES
('root@localhost','root','root/',encrypt('apassword', CONCAT('$5$', MD5(RAND()))) );

installation de postfix : choisir le mode internet site apt-get install postfix postfix-mysql

emacs /etc/mailname
emacs /etc/postfix/main.cf
myorigin=/etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name
relayhost =
inet_interfaces = all
mynetworks_style = host
# masquerade_domains = mail.example.com www.example.com !sub.dyndomain.com
# masquerade_exceptions = root
local_recipient_maps =
mydestination =
Then will set a few numbers.
delay_warning_time = 4h
unknown_local_recipient_reject_code = 450
maximal_queue_lifetime = 7d
minimal_backoff_time = 1000s
maximal_backoff_time = 8000s
smtp_helo_timeout = 60s
smtpd_recipient_limit = 16
smtpd_soft_error_limit = 3
smtpd_hard_error_limit = 12
smtpd_helo_restrictions = permit_mynetworks, warn_if_reject reject_non_fqdn_hostname, reject_invalid_hostname, permit
smtpd_sender_restrictions = permit_mynetworks, warn_if_reject reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_pipelining, permit
smtpd_client_restrictions = reject_rbl_client sbl.spamhaus.org, reject_rbl_client blackholes.easynet.nl
smtpd_recipient_restrictions = reject_unauth_pipelining, permit_mynetworks, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, permit
smtpd_data_restrictions = reject_unauth_pipelining
smtpd_helo_required = yes
smtpd_delay_reject = yes
disable_vrfy_command = yes
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
virtual_mailbox_base = /var/spool/mail/virtual
virtual_mailbox_maps = mysql:/etc/postfix/mysql_mailbox.cf
virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_domains.cf
# transport_maps = mysql:/etc/postfix/mysql_transport.cf
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000

cp /etc/aliases /etc/postfix/aliases
postalias /etc/postfix/aliases

mkdir /var/spool/mail/virtual
groupadd --system virtual -g 5000
useradd --system virtual -u 5000 -g 5000
chown -R virtual:virtual /var/spool/mail/virtual

emacs /etc/postfix/mysql_mailbox.cf
user=mail
password=XXXXXX
dbname=mail
table=users
select_field=maildir
where_field=id
hosts=127.0.0.1
additional_conditions = and enabled = 1

emacs /etc/postfix/mysql_alias.cf
user=mail
password=XXXXXX
dbname=mail
table=aliases
select_field=destination
where_field=mail
hosts=127.0.0.1
additional_conditions = and enabled = 1

emacs /etc/postfix/mysql_domains.cf
user=mail
password=XXXXXX
dbname=mail
table=domains
select_field=domain
where_field=domain
hosts=127.0.0.1
additional_conditions = and enabled = 1

installation des courriers : choisir "no webdirectories"

apt-get install courier-base courier-authdaemon courier-authlib-mysql courier-imap courier-imap-ssl courier-ssl

emacs /etc/courier/authdaemonrc
authmodulelist="authmysql"
DEBUG_LOGIN=2

emacs /etc/courier/authmysqlrc
MYSQL_USERNAME mail
MYSQL_PASSWORD XXXXXX
MYSQL_DATABASE mail
MYSQL_USER_TABLE users
MYSQL_CRYPT_PWFIELD crypt

MYSQL_CLEAR_PWFIELD clear

MYSQL_MAILDIR_FIELD concat(home,'/',maildir)
MYSQL_WHERE_CLAUSE enabled=1

/etc/init.d/postfix restart

apt-get install mailutils

tester avec : mail email@email.com vérifier les logs : tail -f /var/log/mail.log