Install Postfix to configure SMTP Server. This example shows to configure SMTP-Auth to use Dovecot’s SASL function. |
|
[1] |
Configure Postfix. ( Postfix is installed by default even if you installed CentOS with Minimal.) |
[root@mail ~]#vi /etc/postfix/main.cf# line 75: uncomment and specify hostnamemyhostname =mail.server.world# line 83: uncomment and specify domain namemydomain =server.world# line 99: uncommentmyorigin = $mydomain# line 116: changeinet_interfaces =all# line 119: change if you use only IPv4inet_protocols =ipv4# line 164: addmydestination = $myhostname, localhost.$mydomain, localhost, $mydomain# line 264: uncomment and specify your LANmynetworks = 127.0.0.0/8,10.0.0.0/24# line 419: uncomment (use Maildir)home_mailbox = Maildir/# line 545: uncomment, line 546: addheader_checks = regexp:/etc/postfix/header_checksbody_checks = regexp:/etc/postfix/body_checks# line 571: addsmtpd_banner = $myhostname ESMTP# add at the last line# limit an email size 10Mmessage_size_limit = 10485760# limit mailbox 1Gmailbox_size_limit = 1073741824# for SMTP-Auth settingssmtpd_sasl_type = dovecot
|
Install Dovecot to Configure POP/IMAP Server. This example shows to configure to provide SASL function to Postfix. |
[root@mail ~]#yum -y install dovecot[root@mail ~]#vi /etc/dovecot/dovecot.conf# line 31: change ( if not use IPv6 )listen =*[root@mail ~]#vi /etc/dovecot/conf.d/10-auth.conf# line 9: uncomment and change ( allow plain text auth )disable_plaintext_auth =no# line 97: addauth_mechanisms = plainlogin[root@mail ~]#vi /etc/dovecot/conf.d/10-mail.conf# line 30: uncomment and addmail_location =maildir:~/Maildir[root@mail ~]#vi /etc/dovecot/conf.d/10-master.conf# line 84-86: uncomment and add# Postfix smtp-auth
|
Configure for your Mail Client on your PC. This example shows with Windows Live Mail. |
|
[1] |
Start Windows Live mail and move to “Account” tab and Click “Email”. |
[2] |
Input email address, account’s password, sender’s name and check a box ‘Configure Manually’ and go next. |
[3] |
Select IMAP or POP. This example selects IMAP. And input other information of your Mail server. Don’t forget to check a box ‘this server requires to authenticate’ at the bottom. |
[4] |
Click ‘Finish’. |
[5] |
Connect and get server’s folder settings automatically. |
Configure SSL settings in order to encrypt datas in connection. |
|
[1] |
Create certificates first, see here. |
[2] |
Configure Postfix and Dovecot for SSL |
[root@mail ~]#vi /etc/postfix/main.cf# add at the last linesmtpd_use_tls = yes
|
Configure on client. Change settings like following example. (if you use PO3S, input ‘995 for incoming mail) |
Click syncronize on Windows Live Mail, then following warning is shown because certificate file is created on your server. It’s no ploblem. Click ‘Yes’ to Proceed, then it’s possible to send/receive emails trough SSL connection. |
Create a your server’s original SSL Certificate. If you use your server as a business, it had better buy and use a Formal Certificate from Verisigh and so on. |
[root@www ~]#cd /etc/pki/tls/certs[root@www certs]#make server.keyumask 77 ; \/usr/bin/openssl genrsa -aes128 2048 > server.keyGenerating RSA private key, 2048 bit long modulus
|
[1] |
Install Clamav |
[root@mail ~]#yum –enablerepo=rpmforge -y install clamav# install from RPMforge[root@mail ~]#vi /etc/freshclam.conf# line 122: make it comment#NotifyClamd /etc/clamd.conf[root@mail ~]#freshclam# update pattern filesClamAV update process started at Sun Jul 10 22:10:08 2011
|
[2] |
Try to scan |
# try to scan[root@mail ~]#clamscan –infected –remove –recursive /home———– SCAN SUMMARY ———–
|
[root@mail ~]#yum –enablerepo=rpmforge -y install clamd# install from RPMforge[root@mail ~]#wget http://thewalter.net/stef/software/clamsmtp/clamsmtp-1.10.tar.gz[root@mail ~]#tar zxvf clamsmtp-1.10.tar.gz[root@mail ~]#cd clamsmtp-1.10[root@mail clamsmtp-1.10]#./configure[root@mail clamsmtp-1.10]#make[root@mail clamsmtp-1.10]#make install[root@mail clamsmtp-1.10]#cp ./doc/clamsmtpd.conf /etc[root@mail clamsmtp-1.10]#cd[root@mail ~]#vi /etc/clamsmtpd.conf# line 11: changeOutAddress:127.0.0.1:10026# line 29: uncomment and changeListen:127.0.0.1:10025# line 32: changeClamAddress:/var/run/clamav/clamd.sock# line 35: uncommentHeader: X-Virus-Scanned: ClamAV using ClamSMTP# line 38: uncommentTempDirectory: /tmp# line 41: uncommentAction: drop# line 50: uncommentUser: clamav[root@mail ~]#vi /etc/rc.d/init.d/clamsmtp# create init script#!/bin/bash# clamsmtpd: Start/Stop clamsmtpd## chkconfig: – 65 40# description: Clamsmtpd is smtpd for Clamav Antivirus daemon.## processname: clamsmtpd# pidfile: /var/run/clamav/clamsmtpd.pid. /etc/rc.d/init.d/functions. /etc/sysconfig/networkCONFIG_FILE=/etc/clamsmtpd.confPID_DIR=/var/run/clamavRETVAL=0start() {echo -n $”Starting ClamSmtpd: “daemon /usr/local/sbin/clamsmtpd -f $CONFIG_FILE -p $PID_DIR/clamsmtpd.pidRETVAL=$?echo[ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamsmtpdreturn $RETVAL}stop() {echo -n $”Stopping ClamSmtpd: “killproc clamsmtpdRETVAL=$?echo[ $RETVAL -eq 0 ] && rm -f /var/run/clamsmtp/clamsmtpd.pid /var/lock/subsys/clamsmtpdreturn $RETVAL}case “$1” instart)start;;stop)stop;;status)status clamsmtpd;;restart)stopstart;;condrestart)[ -f /var/lock/subsys/clamsmtpd ] && restart || :;;*)echo $”Usage: $0 {start|stop|status|restart}”exit 1esacexit $?[root@mail ~]#chmod 755 /etc/rc.d/init.d/clamsmtp[root@mail ~]#/etc/rc.d/init.d/clamd startStarting Clam AntiVirus Daemon: Bytecode: Security mode set to “TrustSigned”.
|
[2] |
Configure Postfix |
[root@mail ~]#vi /etc/postfix/main.cf# add at the last linecontent_filter = scan:127.0.0.1:10025[root@mail ~]#vi /etc/postfix/master.cf# add at the last linescan unix – – n – 16 smtp-o smtp_data_done_timeout=1200-o smtp_send_xforward_command=yes-o disable_dns_lookups=yes127.0.0.1:10026 inet n – n – 16 smtpd-o content_filter=-o local_recipient_maps=-o relay_recipient_maps=-o smtpd_restriction_classes=-o smtpd_client_restrictions=-o smtpd_helo_restrictions=-o smtpd_sender_restrictions=-o smtpd_recipient_restrictions=permit_mynetworks,reject-o mynetworks_style=host-o smtpd_authorized_xforward_hosts=127.0.0.0/8[root@mail ~]#/etc/rc.d/init.d/postfix restartShutting down postfix:[ OK ]Starting postfix:[ OK ] |
These lines below are added in header section of emails after this configuration. |
Try to send test virus with email, then it will not send to a mailbox and logs like below are recorded. |
Install httpd |
[root@www ~]#yum -y install httpd# remove welcome page[root@www ~]#rm -f /etc/httpd/conf.d/welcome.conf# remove default error page[root@www ~]#rm -f /var/www/error/noindex.html |
[2] |
Configure httpd. |
[root@www ~]#vi /etc/httpd/conf/httpd.conf# line 44: changeServerTokensProd# line 76: change to ONKeepAliveOn# line 262: Admin’s addressServerAdminroot@server.world# line 276: change to your server’s nameServerNamewww.server.world:80# line 338: changeAllowOverrideAll# line 402: add file name that it can access only with directory’s nameDirectoryIndex index.htmlindex.htm# line 536: changeServerSignatureOff# line 759: make it comment#AddDefaultCharset UTF-8[root@www ~]#/etc/rc.d/init.d/httpd startStarting httpd:[ OK ][root@www ~]#chkconfig httpd on |
Install MySQL for Database Server. |
[root@www ~]#yum -y install mysql-server[root@www ~]#/etc/rc.d/init.d/mysqld startInitializing MySQL database: Installing MySQL system tables…OKFilling help tables…OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/usr/bin/mysqladmin -u root password ‘new-password’/usr/bin/mysqladmin -u root -h www.server.world password ‘new-password’Alternatively you can run:/usr/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd /usr ; /usr/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd /usr/mysql-test ; perl mysql-test-run.plPlease report any problems with the /usr/bin/mysqlbug script!Starting mysqld: [ OK ][root@www ~]#chkconfig mysqld on[root@www ~]#mysql -u root# connect to MySQLWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.1.52 Source distributionCopyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.This software comes with ABSOLUTELY NO WARRANTY. This is free software,and you are welcome to modify and redistribute it under the GPL v2 licenseType ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.# show user infomysql>select user,host,password from mysql.user;# set root passwordmysql>set password for root@localhost=password(‘password’);Query OK, 0 rows affected (0.00 sec)# set root passwordmysql>set password for root@’127.0.0.1’=password(‘password’);Query OK, 0 rows affected (0.00 sec)# set root passwordmysql>set password for root@’www.server.world’=password(‘password’);Query OK, 0 rows affected (0.00 sec)# delete anonymous usermysql>delete from mysql.user where user=”;Query OK, 2 rows affected (0.00 sec)mysql>select user,host,password from mysql.user;mysql>exit# quitBye
|
MySQL
root@mail ~]#mysql -u root -p# connect to MySQLEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.1.52 Source distributionCopyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.This software comes with ABSOLUTELY NO WARRANTY. This is free software,and you are welcome to modify and redistribute it under the GPL v2 licenseType ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.# create “postfixadmin” DB ( input any password you like on ‘password’ section )mysql>create database postfixadmin character set utf8 collate utf8_bin;Query OK, 1 row affected (0.00 sec)mysql>grant all privileges on postfixadmin.* to postfixadmin@’localhost’ identified by ‘password’;Query OK, 0 rows affected (0.00 sec)mysql>flush privileges;Query OK, 0 rows affected (0.00 sec)mysql>exitBye |
[2] |
Install PostfixAdmin (Download lataest version of it) |
[root@mail ~]#yum -y install php-mysql php-imap[root@mail ~]#wget http://ftp.jaist.ac.jp/pub/sourceforge/p/po/postfixadmin/postfixadmin/postfixadmin-2.3.5/postfixadmin-2.3.5.tar.gz[root@mail ~]#tar zxvf postfixadmin-2.3.5.tar.gz[root@mail ~]#mv postfixadmin-2.3.5 /var/www/html/postfixadmin[root@mail ~]#vi /var/www/html/postfixadmin/config.inc.php# line 26: change$CONF[‘configured’] =true;# line 31: change after Web settings (input it generated on [5] section)$CONF[‘setup_password’] = ‘xxxxxxxxxx‘;# line 43: change$CONF[‘default_language’] = ‘ja‘;# line 51,52,53: change to the DB info for postfixadmin$CONF[‘database_user’] = ‘postfixadmin‘;
|
[3] |
Access to “http://(your server’s hostname or IP address)/postfixadmin/setup.php”. Then, following screen is shown, click “Lost password?” on right under. |
[4] |
Input setup password. |
[5] |
Set generated hash on config file (back to [2]). Next, input setup password and email address, admin-password and click “add admin” button. |
[6] |
Admin user is added. Initial settings is just completed. |
[7] |
Access to “http://(your server’s hostname or IP address)/postfixadmin/login.php”. Then, login screen is shown like follows. Login with admin user you added. |
[8] |
Just logined. It’s possible to configure Postfix on here. |
[root@mail ~]#yum –enablerepo=epel -y install mailgraph# install from EPEL[root@mail ~]#vi /etc/httpd/conf.d/mailgraph.confAlias /mailgraph /usr/share/mailgraphAddHandler cgi-script .cgi<Directory /usr/share/mailgraph/>
|
[2] |
Access to ‘http://(your server’s name or IP address)/mailgraph/’ with web browser. Then following screen is shown and it’s possible to make sure mail log summary. |