linux

centos - postfix

sysman 2020. 12. 28. 16:07

 

#hostnamectl set-hostname mail.example.com

 

#vim /etc/hosts

192.168.10.252 mail.example.com

 

# dnf install -y postfix

#systemctl enable postfix

#systemctl start postfix

#systemctl status postfix

 

#vi /etc/postfix/main.cf

myhostname = pmail.sangchul.kr

mydomain = sangchul.kr

myorigin = $mydomain

inet_interfaces = all

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

mynetworks = 127.0.0.0/8, 172.16.0.0/24

home_mailbox = Maildir/

 

 

 

 

 

# openssl req -nodes -newkey rsa:2048 -keyout mail.key -out mail.csr

KR

Seoul

Seoul

example.company

it

mail.example.com

postfix@example.com

 

 

 

#openssl x509 -req -days 365 -in mail.csr -signkey mail.key -out mail.crt

 

#ls -l | egrep mail

 

#mkdir -p /etc/postfix/ssl

# cp mail.key mail.crt /etc/postfix/ssl/

 

 

#vi /etc/postfix/main.cf

...

smtpd_use_tls = yes

smtpd_tls_cert_file = /etc/postfix/ssl/mail.crt

smtpd_tls_key_file = /etc/postfix/ssl/mail.key

smtpd_tls_security_level = may

 

 

#systemctl restart postfix

# useradd mailtest

# passwd mailtest

 

 

[root@mail ~]# telnet localhost 25

Trying ::1...

Connected to localhost.

Escape character is '^]'.

220 mail.example.com ESMTP Postfix

ehlo localhost

250-mail.example.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-STARTTLS

250-ENHANCEDSTATUSCODES

250-8BITMIME

250-DSN

250 SMTPUTF8

mail from:postfix@example.com

250 2.1.0 Ok

rcpt to:mailtest@example.com

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

hello mail test

.

250 2.0.0 Ok: queued as 7A93D400E073

quit

221 2.0.0 Bye

Connection closed by foreign host.

[root@mail ~]#

 

[root@mail ~]# dnf -y install mailx

[root@mail ~]# mailx -s "MAIL TEST" -r postfix@example.com mailtest@example.com

test is test!!!!!!!!!!

.

EOT

[root@mail ~]# mailq

Mail queue is empty

[root@mail ~]# cat /home/mailtest/Maildir/new/1609138

1609138196.V803I805203M206128.mail.example.com  1609138395.V803I805205M600506.mail.example.com

1609138317.V803I805204M108631.mail.example.com  1609138473.V803I805206M555541.mail.example.com

[root@mail ~]# cat /home/mailtest/Maildir/new/1609138196.V803I805203M206128.mail.example.com

Return-Path: <postfix@example.com>

X-Original-To: mailtest@example.com

Delivered-To: mailtest@example.com

Received: from localhost (localhost [IPv6:::1])

        by mail.example.com (Postfix) with ESMTP id 7A93D400E073

        for <mailtest@example.com>; Mon, 28 Dec 2020 01:49:23 -0500 (EST)

Message-Id: <20201228064938.7A93D400E073@mail.example.com>

Date: Mon, 28 Dec 2020 01:49:23 -0500 (EST)

From: postfix@example.com

 

hello mail test

[root@mail ~]# cat /home/mailtest/Maildir/new/16091383

1609138317.V803I805204M108631.mail.example.com  1609138395.V803I805205M600506.mail.example.com

[root@mail ~]# cat /home/mailtest/Maildir/new/1609138317.V803I805204M108631.mail.example.com

Return-Path: <postfix@example.com>

X-Original-To: mailtest@example.com

Delivered-To: mailtest@example.com

Received: by mail.example.com (Postfix, from userid 0)

        id 0DF20400E073; Mon, 28 Dec 2020 01:51:57 -0500 (EST)

Date: Mon, 28 Dec 2020 01:51:56 -0500

From: postfix@example.com

To: mailtest@example.com

Subject: MAIL TEST

Message-ID: <5fe9808c.mdmmbl8NFTnlsL6m%postfix@example.com>

User-Agent: Heirloom mailx 12.5 7/5/10

MIME-Version: 1.0

Content-Type: text/plain; charset=us-ascii

Content-Transfer-Encoding: 7bit

 

 mail is testdnf -y install mailx!

[root@mail ~]#

'linux' 카테고리의 다른 글

centos - 초기세팅  (0) 2020.12.30
Centos -backup  (0) 2020.12.29
centos -dns 서버 설치  (0) 2020.12.28
Centos 8 - DB 설치  (0) 2020.12.27
Centos -samba  (0) 2020.12.27