본문 바로가기

Engineering/__00. Linux

[Sendmail/Postfix]

[메일서버 도메인 적용]

1. /etc/hosts/hosts   

/etc/hosts
127.0.0.1 localhost.localdomain localhost test.qahuni.kr test
127.0.1.1 test
125.140.117.5   test.qahuni.kr

 

2. # hostnamectl set-hostname

# hostnamectl set-hostname test.qahuni.kr
# hostnamectl
   Static hostname: root@mail:~# hostnamectl
   Static hostname: test.qahuni.kr
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 4b8545291b5e497d8c3652bf559f9ba2
           Boot ID: 1fb096b4c67b4b6eb4fac6c5d9f93d73
    Virtualization: vmware
  Operating System: Ubuntu 20.04.3 LTS
            Kernel: Linux 5.4.0-84-generic
      Architecture: x86-64
#

 

 

[로그 보기]

sendmail 에서 무언가 안될 때 로그 확인이 가장 중요하다. 

tail -f /var/log/mail.log 명령으로 로그를 확인하는데 기본은 자세한 로그가 나오지 않는다.

/etc/mail/sendmail.cf 에서 로그레벨을 변경하여 자세한 로그를 확인하도록 한다.

# log level
O LogLevel=15         (기본값은 9)

더보기

일예로 기본값으로는 smtp 로그인이 실패하는데 그 원인을 보여주지 않는다. 15로 변경하면 다음과 같은 로그가 출력된다.


Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: <-- EHLO QAHUNINOTE
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 250-localhost.localdomain Hello [192.168.11.1], pleased to meet you
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 250-ENHANCEDSTATUSCODES
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 250-PIPELINING
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 250-EXPN
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 250-VERB
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 250-8BITMIME
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 250-SIZE
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 250-DSN
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 250-AUTH DIGEST-MD5 CRAM-MD5
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 250-DELIVERBY
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 250 HELP
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: <-- AUTH DIGEST-MD5
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 334 bm9uY2U9IlNvbXVIcURnZDl5Umk2MWRWaU44UzAxNUZpV1hGa2t4M08zSlJlckVsK1U9IixyZWFsbT0ibG9jYWxob3N0LmxvY2FsZG9tYWluIixxb3A9ImF1dGgsYXV0aC1pbnQsYXV0aC1jb25mIixjaXBoZXI9InJjNC00MCxyYzQtNTYscmM0LGRlcywzZGVzIixtYXhidWY9ODE5MixjaGFyc2V0PXV0Zi04LGFsZ29yaXRobT1tZDUtc2Vzcw==
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 535 5.7.0 authentication failed
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: AUTH failure (DIGEST-MD5): user not found (-20) SASL(-13): user not found: unable to canonify user and get auxprops, relay=[192.168.11.1]
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: --- 421 4.4.1 localhost.localdomain Lost input channel from [192.168.11.1]
Aug 26 11:40:08 localhost sm-mta[218002]: 17Q2e7ff218002: [192.168.11.1] did not issue MAIL/EXPN/VRFY/ETRN during connection to MSP-v4

AUTH 인증 타입에 LOGIN type 이 존재하지 않아서 문제가 되었다.
기본값일 경우에는 did not issue MAIL/EXPN/VRFY/ETRN during connection to MSP-v4 로그만 출력되어 그 원인을 정확히 알 수 없었다.

postfix의 경우에는 /etc/postfix/main.cf 에 다음 설정 변경

# DEBUGGING CONTROL
#
# The debug_peer_level parameter specifies the increment in verbose
# logging level when an SMTP client or server host name or address
# matches a pattern in the debug_peer_list parameter.
#
debug_peer_level = 15

# The debug_peer_list parameter specifies an optional list of domain
# or network patterns, /file/name patterns or type:name tables. When
# an SMTP client or server host name or address matches a pattern,
# increase the verbose logging level by the amount specified in the
# debug_peer_level parameter.
#
debug_peer_list = 127.0.0.1
#debug_peer_list = some.domain
#debug_peer_list = 0.0.0.0

# error msg

BillyBob wrote:
> sendmail v 8.14.4-8.e16.i686 on CentOS 6.6

> I'm getting the following errors in the mail logs every time I try to send an email:


errors? Where does it say "error"?

> STARTTLS: ClientCertFile missing
> STARTTLS: ClientKeyFile missing


Those are warnings which are logged at level > 12.

> STARTTLS=client, start=ok

logged at level > 13.

> The cert file (xxx.pem) is defined in confSERVER_CERT and the private key (xxx.key) is
> defined in confSERVER_KEY.


Server != Client.

> What is going on, and what should I be looking at?



Ignore them or lower LogLevel to 12 (or less, 9 is default).

See also
4.8. Log Level
in doc/op/op.*

--
Note: please read the netiquette before posting. I will almost never
reply to top-postings which include a full copy of the previous
article(s) at the end because it's annoying, shows that the poster
is too lazy to trim his article, and it's wasting the time of all readers.

 

[Mail queue]

1. postfix

# mailq (현재 쌓여 있는 mailq 확인)

# postsuper -d ALL    (or   # postsuper -d mailID) (Mail Queue 비우기)

# postsuper -d ALL deferred  (deferred 된 메일만 비우기)