Hi,
Haven’t had a chance to nice n up my mail server how to yet, and i’m sure some of you are tying to install thing thing on newer distributions. So, here are my notes about installing the techie mail server, its all rough notes, i know in my head what it is, but the description may not be there. feel free to use as is – no support, no guarantees.
SETUP
~~~~~
nano /etc/yum.repos.d/enlartenment.repo
[enlartenment]
name=Enlartenment Repository for $releasever – $basearch
baseurl=http://www.enlartenment.com/packages/fedora/$releasever/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-enlartenment
enabled=1
gpgcheck=1
[enlartenment-sources]
name=Enlartenment Repository for $releasever – Sources
baseurl=http://www.enlartenment.com/packages/fedora/$releasever/SRPMS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-enlartenment
enabled=1
gpgcheck=1
MYSQL
~~~~~
yum install mysql-server mysql-devel mysql
/etc/init.d/mysqld start
mysqladmin -u root password ‘new-password’
mysqladmin -u root -h <yourservername> password ‘new-password’ -p
mysql -u root -p
CREATE DATABASE `TNMailServer`;
USE `TNMailServer`;
CREATE TABLE `TNDomain`
(
`DomainID` int(11) NOT NULL auto_increment,
`StatusCodeID` int(11) default NULL,
`Name` varchar(200) default NULL,
`Description` varchar(255) default NULL,
`PhysicialLocation` varchar(255) default NULL,
`MaxAccounts` int(11) default NULL,
`DateCreated` datetime default NULL,
PRIMARY KEY (`DomainID`),
KEY `IX_Name` (`Name`),
KEY `IX_StatusCodeID` (`StatusCodeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
CREATE TABLE `TNUser`
(
`UserID` int(11) NOT NULL auto_increment,
`DomainID` int(11) default NULL,
`UserTypeID` int(11) default NULL,
`StatusCodeID` int(11) default NULL,
`Name` varchar(100) default NULL,
`EmailAddress` varchar(200) default NULL,
`Password` varchar(25) default NULL,
`MailDirLocation` varchar(255) default NULL,
`DateCreated` datetime default NULL,
`LastLogin` datetime default NULL,
`ForwardAdddress` varchar(255) default NULL,
`NotifyAddress` varchar(255) default NULL,
`Quota` int(11) default NULL,
PRIMARY KEY (`UserID`),
KEY `FK_DomainID` (`DomainID`),
KEY `IX_UserTypeID` (`UserTypeID`),
KEY `IX_StatusCodeID` (`StatusCodeID`),
KEY `IX_EmailAddress` (`EmailAddress`),
KEY `IX_ForwardAdddress` (`ForwardAdddress`),
KEY `IX_LastLogin` (`LastLogin`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
create table `TNAutoResponse`
(
`AutoResponseID` int NOT NULL AUTO_INCREMENT ,
`From` varchar (255) ,
`To` varchar (255) ,
`DateCreated` datetime ,
PRIMARY KEY ( `AutoResponseID`),
KEY `IX_From` (`From`),
KEY `IX_To` (`To`),
KEY `IX_DateCreated` (`DateCreated`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
alter table `TNUser` add constraint `FK_TNUser_DomainID` foreign key(`DomainID`) references `TNDomain` (`DomainID`);
insert into `TNDomain`(`DomainID`,`StatusCodeID`,`Name`,`Description`,`PhysicialLocation`,`MaxAccounts`,`DateCreated`)
values (1,1,’domain.tld’,’Test Domain’,’/var/spool/postfix/virtual/domain.tld’,100,’2008-01-01 00:00:00′);
insert into `TNUser`(`UserID`,`DomainID`,`UserTypeID`,`StatusCodeID`,`Name`,`EmailAddress`,`Password`,`PasswordMD5`,`MailDirLocation`,`DateCreated`,`LastLogin`,`ForwardAdddress`,`NotifyAddress`)
values (1,1,3,1,’Admin’,’root@domain.tld’,’nimda’,’domain.tld/root/’,’2008-01-01 00:00:00′,NULL,NULL,NULL,NULL),
(2,1,1,1,’User’,’user@domain.tld’,’pass’,’domain.tld/user/’,’2008-01-01 00:00:00′,NULL,NULL,NULL,NULL);
grant select,update on TNMailServer.* to courier@localhost identified by ‘password’;
grant select on TNMailServer.* to postfix@localhost identified by ‘password’;
SASL
yum install cyrus-sasl cyrus-sasl-md5
nano /usr/lib/sasl2/smtpd.conf
pwcheck_method: authdaemond
log_level: 3
mech_list: PLAIN LOGIN CRAM-MD5 DIGEST-MD5
authdaemond_path:/var/spool/authdaemon/socket
POSTFIX
wget http://archive.mgm51.com/mirrors/postfix-source/official/postfix-2.4.6.tar.gz
wget http://vda.sourceforge.net/VDA/postfix-2.4.6-vda-ng.patch.gz
gunzip postfix-2.4.6-vda-ng.patch.gz
patch -p1 < postfix-2.4.6-vda-ng.patch
make -f Makefile.init makefiles ‘CCARGS=-DHAS_MYSQL -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DUSE_TLS -I/usr/include/mysql -I/usr/include/sasl’ \
‘AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -lsasl2 -lssl -lcrypto’
groupadd postfix
useradd postfix -g postfix
groupadd postdrop
make install
mkdir /var/spool/postfix/virtual
chown postfix.postdrop /var/spool/postfix/virtual
cd /etc/postfix
nano TNDomain.cf
user = postfix
password = password
hosts = localhost
dbname = TNMailServer
query = SELECT Name FROM TNDomain WHERE Name=’%s’
nano TNUser.cf
user = postfix
password = password
dbname = TNMailServer
hosts = localhost
query = SELECT EmailAddress FROM TNUser where EmailAddress=’%s’ AND StatusCodeID=1
nano TNForward.cf
user = postfix
password = password
dbname = TNMailServer
hosts = localhost
query = SELECT ForwardAddress FROM TNUser WHERE EmailAddress=’%s’ AND ForwardAddress IS NOT NULL
nano TNMailbox.cf
user = postfix
password = password
dbname = TNMailServer
hosts = localhost
query = SELECT MailDirLocation FROM TNUser where EmailAddress=’%s’
nano TNQuota.cf
user = postfix
password = password
hosts = localhost
dbname = TNMailServer
query = SELECT Quota FROM TNUser WHERE EmailAddress=’%s’
postconf -e ‘myhostname = doozymail1.doozycards.com’
postconf -e ‘mydestination = doozymail1, doozymail1.doozycards.com, localhost’
postconf -e ‘mynetworks = 127.0.0.1’
postconf -e ‘myorigin = $myhostname’
postconf -e ‘virtual_transport = virtual’
postconf -e ‘virtual_mailbox_base = /var/spool/postfix/virtual’
postconf -e ‘virtual_alias_maps = proxy:mysql:/etc/postfix/TNForward.cf, proxy:mysql:/etc/postfix/TNUser.cf’
postconf -e ‘virtual_mailbox_domains = proxy:mysql:/etc/postfix/TNDomain.cf’
postconf -e ‘virtual_mailbox_maps = proxy:mysql:/etc/postfix/TNMailbox.cf’
postconf -e ‘virtual_mailbox_limit = 500000000’
postconf -e ‘virtual_mailbox_limit_maps = mysql:/etc/postfix/TNQuota.cf’
postconf -e ‘virtual_mailbox_limit_inbox = no’
postconf -e ‘virtual_maildir_extended = yes’
postconf -e ‘virtual_create_maildirsize = yes’
postconf -e ‘virtual_mailbox_limit_override = yes’
postconf -e ‘virtual_overquota_bounce = yes’
postconf -e ‘virtual_minimum_uid = 500’
postconf -e ‘virtual_gid_maps = 501’
postconf -e ‘virtual_uid_maps = static:501’
postconf -e ‘virtual_gid_maps = static:501’
postconf -e ‘virtual_uid_maps = static:500’
postconf -e ‘smtpd_sasl_auth_enable = yes’
postconf -e ‘broken_sasl_auth_clients = yes’
postconf -e ‘smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination’
postconf -e ‘smtpd_tls_cert_file = /etc/postfix/smtpd.cert’
postconf -e ‘smtpd_tls_key_file = /etc/postfix/smtpd.key’
postconf -e ‘smtpd_use_tls = yes’
postconf -e ‘smtpd_tls_cert_file = /etc/postfix/smtpd.cert’
postconf -e ‘smtpd_tls_key_file = /etc/postfix/smtpd.key’
postconf -e ‘inet_interfaces = all’
postconf -e ‘home_mailbox = Maildir/’
cd /etc/postfix
openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509
COURIER
~~~~~~~
yum install courier-imap courier-authlib-mysql
nano /etc/authlib/authdaemonrc
authmodulelist=”authmysql”
nano /etc/authlib/authmysqlrc
MYSQL_SERVER localhost
MYSQL_USERNAME courier
MYSQL_PASSWORD password
MYSQL_PORT 0
MYSQL_OPT 0
MYSQL_DATABASE TNMailServer
MYSQL_USER_TABLE TNUser
MYSQL_CRYPT_PWFIELD ENCRYPT(Password)
MYSQL_CLEAR_PWFIELD Password
DEFAULT_DOMAIN domain.tld
MYSQL_UID_FIELD 500
MYSQL_GID_FIELD 501
MYSQL_LOGIN_FIELD EmailAddress
MYSQL_HOME_FIELD “/var/spool/postfix/virtual”
MYSQL_MAILDIR_FIELD MailDirLocation
MYSQL_NAME_FIELD Name
MYSQL_QUOTA_FIELD Quota
MYSQL_WHERE_CLAUSE StatusCodeID=1
mkdir /var/spool/postfix/virtual/domain.tld
/usr/lib/courier-imap/bin/maildirmake /var/spool/postfix/virtual/domain.tld/root
/usr/lib/courier-imap/bin/maildirmake /var/spool/postfix/virtual/domain.tld/user
chmod 755 /var/spool/authdaemon
CLAMAV
yum install clamav clamav-server clamav-update
chown amavis.root /var/log/freshclam.log
chown amavis.root /var/lib/clamav -R
nano /etc/freshclam.conf
/etc/init.d/clamd.amavisd start
SPAMASSASSIN
yum install perl-Mail-DKIM spamassassin
AMAVIS
yum install amavisd-new
/etc/init.d/amavisd start
nano /etc/postfix/master.cf
pickup fifo n – n 60 1 pickup
-o content_filter=
-o receive_override_options=no_header_body_checks
smtp-amavis unix – – y – 2 smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o disable_dns_lookups=yes
127.0.0.1:10025 inet n – y – – smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o strict_rfc821_envelopes=yes
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000
-o receive_override_options=no_header_body_checks
postconf -e ‘content_filter=smtp-amavis:[localhost]:10024’
RAZOR
razor-admin -d -create
razor-admin -register
DKIM Outbound
http://downloads.sourceforge.net/dkimproxy/dkimproxy-1.0.1.tar.gz
./configure –prefix=/usr/local/dkimproxy
groupadd dkim
useradd dkim -g dkim
cp sample-dkim-init-script.sh /etc/init.d/dkim
chmod 755 /etc/init.d/dkim
cd /usr/local/dkimproxy/etc
openssl genrsa -out private.key 1024
openssl rsa -in private.key -pubout -out public.key
cp dkimproxy_out.conf.example dkimproxy_out.conf
nano dkimproxy_out.conf
cd ..
chown dkim.dkim -R *
chmod 700 -R *
/etc/init.d/dkim start-out
nano /etc/postfix/master.cf
submission inet n – n – – smtpd
-o smtpd_etrn_restrictions=reject
-o smtpd_sasl_auth_enable=yes
-o content_filter=dksign:[127.0.0.1]:10027
-o receive_override_options=no_address_mappings
-o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject
dksign unix – – n – 10 smtp
-o smtp_send_xforward_command=yes
-o smtp_discard_ehlo_keywords=8bitmime,starttls
127.0.0.1:10028 inet n – n – 10 smtpd
-o content_filter=
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o smtpd_authorized_xforward_hosts=127.0.0.0/8