You cannot see this page without javascript.

CentOS7 Mail Server Setting

CentOS 조회 수 8096 추천 수 0 2015.06.13 20:01:35

이 글은 Postfix, Dovecot을 이용하여 Mail서버를 구성하는 과정이다.

Setup mail server on centos 7

1. Installing packages

2. SMTP Server configuration

3. SMTP Server testing

4. IMAP & POP Server configuration

5. IMAP & POP Server testing

6. Installing RoundCube Web-Mail

 

구축 환경: CentOS7-x64bit

 

Installing packages

Step 1 >> postfix와 dovecot 페키지 설치

[root@localhost ~]# yum -y install postfix dovecot

Create SSL certificate

Step 2 >> OpenSSL을 이용하여 SSL 인증서 만들기

[root@localhost ~]# cd /etc/postfix/ssl
[root@localhost ssl]# openssl genrsa -des3 -out server.key 2048
[root@localhost ssl]# openssl rsa -in server.key -out server.key.insecure
[root@localhost ssl]# mv server.key server.key.secure
[root@localhost ssl]# mv server.key.insecure server.key

[root@localhost ssl]# openssl req -new -key server.key -out server.csr
[root@localhost ssl]# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

SMTP Server configuration

Postfix configuration

Step 3 >> main.cf 설정

[root@localhost ssl]# vi /etc/postfix/main.cf
#inet_interfaces = localhost
#mydestination = $myhostname, localhost.$mydomain, localhost
mydomain = localhost
myorigin = $mydomain
home_mailbox = mail/
mynetworks = 127.0.0.0/8
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_local_domain =
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 1
smtpd_tls_key_file = /etc/postfix/ssl/server.key
smtpd_tls_cert_file = /etc/postfix/ssl/server.crt
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom

Step 4 >> master.cf 설정

[root@localhost ssl]# vi /etc/postfix/master.cf
smtp      inet  n       -       n       -       -       smtpd
#smtp      inet  n       -       n       -       1       postscreen
#smtpd     pass  -       -       n       -       -       smtpd
#dnsblog   unix  -       -       n       -       0       dnsblog
#tlsproxy  unix  -       -       n       -       0       tlsproxy
submission inet n       -       n       -       -       smtpd
  -o syslog_name=postfix/submission
#  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
smtps     inet  n       -       n       -       -       smtpd
  -o syslog_name=postfix/smtps
#  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING

Dovecot configuration

Step 5 >> 10-master.conf 설정

[root@localhost ssl]# vi /etc/dovecot/conf.d/10-master.conf
  # Postfix smtp-auth
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }

Step 6 >> 10-auth.conf 설정

[root@localhost ssl]# vi /etc/dovecot/conf.d/10-auth.conf
# Space separated list of wanted authentication mechanisms:
#   plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi otp skey
#   gss-spnego
# NOTE: See also disable_plaintext_auth setting.
auth_mechanisms = plain login

Step 7 >> postfix와 dovecot 재시작 / 자동시작 등록

[root@localhost ssl]# systemctl restart postfix
[root@localhost ssl]# systemctl enable postfix
[root@localhost ssl]# systemctl restart dovecot
[root@localhost ssl]# systemctl enable dovecot

Step 8 >> smtp 서버 방화벽 설정

[root@localhost ssl]# firewall-cmd --permanent --add-service=smtp
[root@localhost ssl]# firewall-cmd --permanent --add-port=587/tcp
[root@localhost ssl]# firewall-cmd --permanent --add-port=465/tcp
또는
[root@localhost ssl]# vi /etc/firewalld/zones/public.xml
  <service name="smtp"/>
  <port protocol="tcp" port="465"/>
  <port protocol="tcp" port="587"/>
[root@localhost ssl]# systemctl restart firewalld.service

SMTP Server Test

Step 9 >> telnet 접속

[root@localhost ssl]# telnet localhost 465
Trying localhost...
Connected to localhost.
Escape character is '^]'.
220 localhost ESMTP Postfix
ehlo localhost
250-localhost
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

IMAP POP Server configuration

Dovecot configuration

Step 10 >> 10-mail.conf 설정

[root@localhost ssl]# vi /etc/dovecot/conf.d/10-mail.conf
#   mail_location = maildir:~/Maildir
#   mail_location = mbox:~/mail:INBOX=/var/mail/%u
#   mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
#
# <doc/wiki/MailLocation.txt>
#
mail_location = maildir:~/Maildir

Step 11 >> 20-pop3.conf 설정

[root@localhost ssl]# vi /etc/dovecot/conf.d/10-mail.conf
# Note that Outlook 2003 seems to have problems with %v.%u format which was
# Dovecot's default, so if you're building a new server it would be a good
# idea to change this. %08Xu%08Xv should be pretty fail-safe.
#
pop3_uidl_format = %08Xu%08Xv

Step 12 >> dovecot 재시작

[root@localhost ssl]# systemctl restart dovecot

Step 13 >> imap pop 서버 방화벽 설정

[root@localhost ssl]# firewall-cmd --permanent --add-port=110/tcp
[root@localhost ssl]# firewall-cmd --permanent --add-service=pop3s
[root@localhost ssl]# firewall-cmd --permanent --add-port=143/tcp
[root@localhost ssl]# firewall-cmd --permanent --add-service=imaps
또는
[root@localhost ssl]# vi /etc/firewalld/zones/public.xml
  <service name="pop3s"/>
  <service name="imaps"/>
  <port protocol="tcp" port="110"/>
  <port protocol="tcp" port="143"/>
[root@localhost ssl]# systemctl restart firewalld.service

IMAP POP3 Server Test

Step 14 >> telnet 접속 - pop3

[root@localhost ssl]# telnet localhost 110
Trying localhost...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
quit
+OK Logging out
Connection closed by foreign host.

Step 15 >> telnet 접속 - imap4

[root@localhost ssl]# telnet localhost 143
Trying localhost...
Connected to localhost.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.

Step 16 >> dovecot.conf 설정

[root@localhost ssl]# vi /etc/dovecot/dovecot.conf
# Protocols we want to be serving.
protocols = imap imaps pop3 pop3s lmtp
# A comma separated list of IPs or hosts where to listen in for connections.
# "*" listens in all IPv4 interfaces, "::" listens in all IPv6 interfaces.
# If you want to specify non-default ports or anything more complex,
# edit conf.d/master.conf.
listen = *, ::

Step 17 >> 10-auth.conf 설정

[root@localhost ssl]# vi /etc/dovecot/conf.d/10-auth.conf
# Disable LOGIN command and all other plaintext authentications unless
# SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
# matches the local IP (ie. you're connecting from the same computer), the
# connection is considered secure and plaintext authentication is allowed.
# See also ssl=required setting.
disable_plaintext_auth = no

# Space separated list of wanted authentication mechanisms:
#   plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi otp skey
#   gss-spnego
# NOTE: See also disable_plaintext_auth setting.
auth_mechanisms = plain login

Step 18 >> 10-mail.conf 설정

[root@localhost ssl]# vi /etc/dovecot/conf.d/10-mail.conf
#   mail_location = maildir:~/Maildir
#   mail_location = mbox:~/mail:INBOX=/var/mail/%u
#   mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
#
# <doc/wiki/MailLocation.txt>
#
mail_location = maildir:~/Maildir

Step 19 >> 10-master.conf 설정

[root@localhost ssl]# vi /etc/dovecot/conf.d/10-master.conf
  # Postfix smtp-auth
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }

Step 20 >> 10-ssl.conf 설정

[root@localhost ssl]# vi /etc/dovecot/conf.d/10-ssl.conf
# SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>
# disable plain pop3 and imap, allowed are only pop3+TLS, pop3s, imap+TLS and imaps
# plain imap and pop3 are still allowed for local connections
ssl = yes

# PEM encoded X.509 SSL/TLS certificate and private key. They're opened before
# dropping root privileges, so keep the key file unreadable by anyone but
# root. Included doc/mkcert.sh can be used to easily generate self-signed
# certificate, just make sure to update the domains in dovecot-openssl.cnf
ssl_cert = </etc/postfix/ssl/server.crt
ssl_key = </etc/postfix/ssl/server.key

Step 21 >> dovecot 재시작

[root@localhost ssl]# systemctl restart dovecot

 

Installing RoundCube Web-Mail

Downloading RoundCube Web-Mail

Step 22 >> Downloading RoundCube Web-Mail

개발자 사이트 : roundcube.net

개발자 사이트에 접속하면 아래와 같은 메인 페이지에 접속된다.

 

001.png

 

상단의 'Download' 메뉴를 클릭한다.

 

002.png

 

다운로드 항목중 Complete 버전의 'DOWNLOAD' 버튼을 클릭한다.

 

003.png

 

SourceForge 사이트로 연결되며 5초의 시간이 지나면 다운로드 창이 나타나며, 다운로드 창에서 '저장' 버튼을 클릭하여 다운로드를 받는다.

 

004.png

 

다운로드가 완료되면 '다운로드 보기' 버튼을 클릭한다.

 

005.png

 

다운로드 보기창의 리스트에서 다운로드 받은 항목이 보일것이다.

해당 리스트에서 우클릭을 한다.

 

006.png

 

'다운로드 링크 복사' 메뉴를 클릭한다.

 

서버에 ftp server가 있다면 다운로드 받은 파일을 올려도 되고 ssh를 통한 콘솔 접속 상황이면 wget명령을 이용하여 복사한 주소로 파일을 다운로드 받는다.

[root@localhost ssl]# cd /usr/src
[root@localhost src]# wget http://jaist.dl.sourceforge.net/project/roundcubemail/roundcubemail/1.1.2/roundcubemail-1.1.2-complete.tar.gz

Step 23 >> Installing RoundCube Web-Mail

[root@localhost src]# tar zxvf roundcubemail-1.1.2-complete.tar.gz
[root@localhost src]# cp -R roundcubemail-1.1.2 /apm/apps/docs/

Step 24 >> RoundCube Web-Mail configuration

RoundCube 환경설정 전에 MySQL에 mail서버를 서포트 할 수 있는 DB와 DB를 관리할 계정을 생성한다.

[root@localhost src]# cd /apm/apps/docs
[root@localhost docs]# mv roundcubemail-1.1.2 mail
[root@localhost docs]# cd mail/config
[root@localhost config]# cp config.inc.php.sample config.inc.php
[root@localhost config]# vi config.inc.php
$config['db_dsnw'] = 'mysql://DB계정:비밀번호@localhost/DB이름';
$config['default_host'] = '본인도메인';
$config['smtp_server'] = '본인도메인';
$config['smtp_port'] = 465;
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';
$config['product_name'] = 'My WebMail';

Step 25 >> RoundCube Web-Mail 접속

http://본인도메인/mail

 

007.png

List of Articles
번호 제목 글쓴이 날짜sort 조회 수
369 Windows7 OEM을 활용하여 클린설치 file [11] LynX 2010-11-06 765
368 Windows7 에서 시스템을 백업/복원하는 가장 쉬운 방법!! file LynX 2010-11-07 334
367 탐색기 메뉴에 '명령 프롬프트 열기'와 '메모장으로 열기' 추가하기 file [14] LynX 2010-11-08 591
366 인터넷 익스플로러 리플레쉬 file LynX 2011-05-02 286
365 활성 네트워크 중복으로 인한 인터넷 연결 안되는 문제 file [12] LynX 2011-05-26 971
364 32bit Driver을 64bi로 설치하기 [8] LynX 2011-06-21 325
363 설치파일(inf)에 대한 이해 [7] LynX 2011-06-22 598
362 inf 설치시 경고창 안뜨게 하기 file [10] LynX 2011-06-22 430
361 로우 포맷(Low level format, 저수준 포맷) 하기 file [11] LynX 2011-07-06 722
360 Win XP Crack file [8] LynX 2011-10-31 269
359 윈도우7 메모리 인식 문재 file [13] LynX 2011-11-30 530
358 RoundCube 첨부 용량 변경 / 한글 수정 [10] LynX 2012-01-31 836
357 윈도우7 알수없는장치 file [8] LynX 2012-03-13 270
356 디지털 서명 file [1] LynX 2012-03-15 445
355 아레한글 사용시 출력물에 음영이 나타나는 현상. file [11] LynX 2012-03-29 1154
354 Xyview DVR서버 연결 [8] LynX 2012-04-19 295
353 HP Officejet 6500A (Plus) 호환 드라이버 [8] LynX 2012-05-16 294
352 IIS에 FastCgi모듈 활성화 시키기 file [12] LynX 2012-11-21 1283
351 윈도우 2008서버에 XE 설치 절차 [9] LynX 2012-11-22 230
350 Windows Server 2012 설치 file LynX 2012-11-23 477

XE Login