和6年能登半島地震により亡くなられた方々のご冥福をお祈りするとともに、被害に遭われた皆さまに対し、心よりお見舞い申し上げます。一日も早く被災地の安全が確保され、復旧が進む事を心よりお祈り申し上げます。

mailコマンドでメール送信メモ

SMTPの挙動を理解するには・・・メールコマンドだと思う。

ドメイン登録なしのテストサーバで実施。

OS: CentOS Linux release 8.1.1911 (Core)

postfixインストール

# yum -y install postfix
Last metadata expiration check: 0:19:05 ago on Mon 09 Nov 2020 06:23:12 PM JST.
Dependencies resolved.
================================================================================
 Package          Architecture    Version                 Repository       Size
================================================================================
Installing:
 postfix          x86_64          2:3.3.1-12.el8          BaseOS          1.4 M
Installing dependencies:
 libicu           x86_64          60.3-2.el8_1            BaseOS          8.8 M

Transaction Summary
================================================================================
Install  2 Packages

Total download size: 10 M
Installed size: 36 M
Downloading Packages:
(1/2): postfix-3.3.1-12.el8.x86_64.rpm          8.4 MB/s | 1.4 MB     00:00
(2/2): libicu-60.3-2.el8_1.x86_64.rpm            21 MB/s | 8.8 MB     00:00
--------------------------------------------------------------------------------
Total                                            16 MB/s |  10 MB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : libicu-60.3-2.el8_1.x86_64                             1/2
  Running scriptlet: libicu-60.3-2.el8_1.x86_64                             1/2
  Running scriptlet: postfix-2:3.3.1-12.el8.x86_64                          2/2
  Installing       : postfix-2:3.3.1-12.el8.x86_64                          2/2
  Running scriptlet: postfix-2:3.3.1-12.el8.x86_64                          2/2
  Verifying        : libicu-60.3-2.el8_1.x86_64                             1/2
  Verifying        : postfix-2:3.3.1-12.el8.x86_64                          2/2

Installed:
  postfix-2:3.3.1-12.el8.x86_64            libicu-60.3-2.el8_1.x86_64

Complete!
# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
compatibility_level = 2
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_interfaces = localhost
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
meta_directory = /etc/postfix
mydestination = $myhostname, localhost.$mydomain, localhost
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix/README_FILES
sample_directory = /usr/share/doc/postfix/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
shlib_directory = /usr/lib64/postfix
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
smtp_tls_CApath = /etc/pki/tls/certs
smtp_tls_security_level = may
smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem
smtpd_tls_key_file = /etc/pki/tls/private/postfix.key
smtpd_tls_security_level = may
unknown_local_recipient_reject_code = 550
# postfix check
#
# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor pr>
   Active: active (running) since Mon 2020-11-09 18:44:47 JST; 10s ago
  Process: 31453 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCE>
  Process: 31451 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, >
  Process: 31446 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, stat>
 Main PID: 31520 (master)
    Tasks: 3 (limit: 11506)
   Memory: 6.3M
   CGroup: /system.slice/postfix.service
           tq31520 /usr/libexec/postfix/master -w
           tq31521 pickup -l -t unix -u
           mq31522 qmgr -l -t unix -u

Nov 09 18:44:46 XXX XXX-XXX-XX-XXX. systemd[1]: Starting Postfix Mail Transport Agen>
Nov 09 18:44:47 XXX XXX-XXX-XX-XXX. postfix/master[31520]: daemon started -- version>
Nov 09 18:44:47 XXX XXX-XXX-XX-XXX. systemd[1]: Started Postfix Mail Transport Agent.
lines 1-17/17 (END)

送信テスト(^^)/

$ telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
XXX XXX-XXX-XX-XXX.localdomain ESMTP Postfix
EHLO localhost
XXX XXX-XXX-XX-XXX.localdomain
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 SMTPUTF8
MAIL FROM: hoge@localhost
250 2.1.0 Ok
RCPT TO: hogehoge@localhost
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subjet: testNo1
Hello world.
Take it easy.
Bye bye!
.
250 2.0.0 Ok: queued as 8EBAFE083E
quit

コメント