서버 설정 · 3 min read · Oct 06, 2025
완벽한 서버 - CentOS 5.4 x86_64 [ISPConfig 2] - 페이지 5
11 Postfix With SMTP-AUTH And TLS
이제 Postfix와 Dovecot를 설치합니다 (Dovecot는 우리의 POP3/IMAP 서버가 될 것입니다):
yum install cyrus-sasl cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-md5 cyrus-sasl-plain postfix dovecot다음으로 SMTP-AUTH와 TLS를 구성합니다:
postconf -e 'smtpd_sasl_local_domain ='
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'smtpd_sasl_security_options = noanonymous'
postconf -e 'broken_sasl_auth_clients = yes'
postconf -e 'smtpd_sasl_authenticated_header = yes'
postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
postconf -e 'inet_interfaces = all'
postconf -e 'mynetworks = 127.0.0.0/8'우리는 /usr/lib64/sasl2/smtpd.conf를 편집하여 Postfix가 PLAIN 및 LOGIN 로그인을 허용하도록 해야 합니다. 32비트 Centos 5.4에서는 /usr/lib/sasl2/smtpd.conf 파일을 대신 편집해야 합니다. 파일은 다음과 같아야 합니다:
vi /usr/lib64/sasl2/smtpd.conf| pwcheck_method: saslauthd mech_list: plain login |
그 후 TLS를 위한 인증서를 생성합니다:
mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csropenssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crtopenssl rsa -in smtpd.key -out smtpd.key.unencryptedmv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650다음으로 TLS를 위한 Postfix를 구성합니다:
postconf -e 'smtpd_tls_auth_only = no'
postconf -e 'smtp_use_tls = yes'
postconf -e 'smtpd_use_tls = yes'
postconf -e 'smtp_tls_note_starttls_offer = yes'
postconf -e 'smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key'
postconf -e 'smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt'
postconf -e 'smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem'
postconf -e 'smtpd_tls_loglevel = 1'
postconf -e 'smtpd_tls_received_header = yes'
postconf -e 'smtpd_tls_session_cache_timeout = 3600s'
postconf -e 'tls_random_source = dev:/dev/urandom'그런 다음 Postfix 설치에서 호스트 이름을 설정합니다 (server1.example.com을 자신의 호스트 이름으로 바꾸는 것을 잊지 마세요):
postconf -e 'myhostname = server1.example.com'이 구성 단계를 마친 후 /etc/postfix/main.cf는 다음과 같아야 합니다 (모든 주석을 제거했습니다):
cat /etc/postfix/main.cf| queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix mail_owner = postfix inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost unknown_local_recipient_reject_code = 550 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin xxgdb $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man sample_directory = /usr/share/doc/postfix-2.3.3/samples readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES smtpd_sasl_local_domain = smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination mynetworks = 127.0.0.0/8 smtpd_tls_auth_only = no smtp_use_tls = yes smtpd_use_tls = yes smtp_tls_note_starttls_offer = yes smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom myhostname = server1.example.com |
기본적으로 CentOS의 Dovecot 데몬은 IMAP 및 IMAPs 서비스만 제공합니다. POP3 및 POP3s도 원하기 때문에 Dovecot을 그렇게 구성해야 합니다. /etc/dovecot.conf를 편집하고 protocols = imap imaps pop3 pop3s 줄을 활성화합니다:
vi /etc/dovecot.conf| [...] # 우리가 제공하고자 하는 프로토콜: imap imaps pop3 pop3s # 만약 dovecot-auth만 사용하고 싶다면, 이것을 "none"으로 설정할 수 있습니다. protocols = imap imaps pop3 pop3s [...] |
이제 Postfix, saslauthd 및 Dovecot을 시작합니다:
chkconfig --levels 235 sendmail off
chkconfig --levels 235 postfix on
chkconfig --levels 235 saslauthd on
chkconfig --levels 235 dovecot on
/etc/init.d/sendmail stop
/etc/init.d/postfix start
/etc/init.d/saslauthd start
/etc/init.d/dovecot startSMTP-AUTH와 TLS가 제대로 작동하는지 확인하려면 다음 명령을 실행합니다:
telnet localhost 25Postfix 메일 서버에 연결한 후 다음을 입력합니다:
ehlo localhost다음과 같은 줄이 보이면
250-STARTTLS및
250-AUTH LOGIN PLAIN모든 것이 정상입니다.
[root@server1 ssl]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 server1.example.com ESMTP Postfix
ehlo localhost
250-server1.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@server1 ssl]#quit를 입력하여 시스템의 쉘로 돌아갑니다.
11.1 Maildir
Dovecot은 Maildir 형식(즉, mbox가 아님)을 사용하므로 서버에 ISPConfig를 설치하는 경우 Management -> Server -> Settings -> Email에서 Maildir을 활성화해야 합니다. 그러면 ISPConfig가 필요한 구성을 수행합니다.
ISPConfig를 설치하고 싶지 않다면, Postfix를 구성하여 사용자의 Maildir로 이메일을 배달해야 합니다 (ISPConfig를 사용하는 경우에도 이 작업을 수행할 수 있습니다 - 해롭지 않습니다 ;-)):
postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='
/etc/init.d/postfix restart새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.