CentOS

Install Mail Server on CentOS

1. Intro

How to Install Mail Server on CentOS.
Sendmail + dovecot + squirrelmail

 

2. Install Sendmail, dovecot

2.1. Install

yum install sendmail sendmail-cf dovecot

2.2. Add Service

### CentOS 7
systemctl enable sendmail
systemctl enable dovecot

### CentOS 6
chkconfig --level 345 sendmail on
chkconfig --level 345 dovecot on

2.3. hostname 변경

vi /etc/hostname or /etc/sysconfig/network ; hostname 수정

HOSTNAME=[hostname]

2.4. sendmail 설정

vi /etc/mail/sendmail.mc ; IP 설정, Domain 설정

### sma<code>thost 설정
define(`SMART_HOST', `[Domain]')dnl

### Domain 설정 - mail domain
Cw[Domain]

### Send client IP 설정
DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=[IP]')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MSP-v4, Port=submission, M=Ea, Addr=[IP]')dnl

### SMTP GreetingMessage 설정 ; 보안을 위해 모든 정보 가림
O SmtpGreetingMessage

vi /etc/mail/local-host-names ; 수신할 메일 도메인 추가

[hostname]

vi /etc/mail/access ; RELAY 설정

[Domain]	RELAY
[IP]		RELAY
192.168.10	RELAY

make -C /etc/mail ; compile

2.5. dovecot 설정

vi /etc/dovecot/dovecot.conf ; 주석 해제

24 protocols = imap pop3 lmtp
30 listen = *, ::
33 base_dir = /var/run/dovecot

vi /etc/dovecot/conf.d/10-ssl.conf

10 ssl = yes

vi /etc/dovecot/conf.d/10-mail.conf

25 mail_location = mbox:~/mail:INBOX=/var/mail/%u
119 mail_access_groups = mail
159 lock_method = fcntl

2.6. Start Service

/etc/init.d/sendmail restart
/etc/init.d/dovecot restart

2.7. Make user

adduser -g mail [user name]
passwd [user name]

 

3. Install squirrelmail

3.1. Download squirrelmail

yum install httpd php -y

wget https://jaist.dl.sourceforge.net/project/squirrelmail/stable/1.4.22/squirrelmail-webmail-1.4.22.tar.gz
tar zxvf squirrelmail-webmail-1.4.22.tar.gz -C /var/www/
cd /var/www
mv squirrelmail-webmail-1.4.22 mail

3.2. setting httpd

vi /etc/httpd/conf/httpd.conf

<VirtualHost *:80>
    DocumentRoot /var/www/mail
    ServerName ms.test.com
    ErrorLog logs/ms.test.com-error_log
    CustomLog logs/ms.test.com-access_log common
</VirtualHost>

<Directory "/var/www/mail">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

3.3. setting squirrelmail

/var/www/mail/configure

2 → 1. Domain : Domain

Make Data directory

mkdir -p /var/local/squirrelmail/data
mkdir -p /var/local/squirrelmail/attach
chown -R apache.apache /var/local/squirrelmail
setsebool P httpd_can_network_connect=1

/etc/init.d/httpd restart

 

Done.

 

 

Back To Top