Mail/Postfix

Postfix 설치 및 설정

서버엔지니어 2023. 3. 10.
728x90

Postfix 이란

Postfix는 IBM Public License 오픈소스 MTA(mail transfer agent)입니다.
qmail과 함께 sendmail을 대처하는 서비스로 많이 사용되고 있습니다. sendmail과의 호환성이 높고,
안전하며 또한 간단한 구조를 가지고 있습니다.

Postfix의 특징

장점
sendmail은 m4 라는 매크로 언어를 사용하여 설정 파일을 생성하는데 예전부터 sendmail 의 설정은 어렵고
가독성이 떨어지기로 악명이 높았습니다. Postfix는 사용자 친화적이고 손쉬운 설정 방식을 제공합니다.
- sendmail은 보안이 큰 문제가 되지 않던 시절에 개발되어 많은 보안 취약점을 가지고 있습니다.
Postfix는RHEL6 부터 기본 MTA(Message Transfer Agent)로 채택된 메일전송서비스로
보안이 sendmail보다 뛰어납니다.
- 빠른 메일 송수신을 염두에 두고 설계/개발되어 sendmail에 비해 빠른 속도를 자랑합니다.

단점
멀티 도메인의 메일 서버 설정이 매우 어렵고, 적용하기 힘들다. 단일 도메인에 대한 메일서버에 강하다.

Postfix 설치

yum remove -y sendmail
yum install -y postfix*

 

Postfix 설정

vi /etc/postfix/main.cf
===============================================================================
myhostname = mail.test.co.kr
mydomain = test.co.kr
myorigin = $myhostname
inet_interfaces = localhost 에서 inet_interfaces = all 로 수정
mynetworks = 0.0.0.0/0 으로 수정

 

아래 주석해제
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
===============================================================================

myhostname = 호스트명설정
mydomain = 도메인설정
myorigin = 송신자 메일주소 도메인
inet_interfaces = 인터넷이 되는 이더넷모두 포함
mynetworks = 메일이 가능한 네트워크 대역대

사용할 MTA 변경

alternatives --config mta

2 개의 프로그램이 'mta'를 제공합니다.

  선택    명령
-----------------------------------------------
   1           /usr/sbin/sendmail.postfix
*+ 2           /usr/sbin/sendmail.sendmail

 

Postfix 재시작 및 시작프로그램 등록

systemctl restart postfix
systemctl enable postfix

Postfix 587 port 설정

 

vi /etc/postfix/master.cf
===============================================================================
submission inet n - n - - smtpd 부분 주석해제
===============================================================================
systemctl restart postfix

 

 

메일전송확인


telnet localhost 25 
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 컴퓨터호스트네임 ESMTP Sendmail 8.14.7/8.14.7; Fri, 2 Oct 2020 09:08:29 +0900
mail from:현재컴퓨터이메일아이디@현재컴퓨터서버이메일주소(ex: test@suwon.tk)
250 2.1.0 test@suwon.tk... Sender ok
rcpt to : 네이버,다음,구글이메일아이디@네이버,다음,구글이메일
250 2.1.5 네이버,다음,구글이메일아이디@네이버,다음,구글이메일... Recipient ok
data
354 Enter mail, end with "." on a line by itself
subject : league of legends funny             
I like LCK, LoL World Cup    
HaHa
.
250 2.0.0 09208T0F002620 Message accepted for delivery
quit
221 2.0.0 techsmile-111792.novalocal closing connection
Connection closed by foreign host.
=========================================================

댓글