目次
メールサーバとして使用する訳ではなく、cronでのスクリプト実行で異常発生した場合等にメールで通知する為だけに利用する。
# postconf mail_version
# yum install postfix
# vi /etc/postfix/main.cf
(〜略〜) # INTERNET HOST AND DOMAIN NAMES # # The myhostname parameter specifies the internet hostname of this # mail system. The default is to use the fully-qualified domain name # from gethostname(). $myhostname is used as a default value for many # other configuration parameters. # #myhostname = host.domain.tld #myhostname = virtual.domain.tld myhostname = hogehoge.mydomain.com ← 追加 # The mydomain parameter specifies the local internet domain name. # The default is to use $myhostname minus the first component. # $mydomain is used as a default value for many other configuration # parameters. # #mydomain = domain.tld mydomain = mydomain.com ← 追加 # SENDING MAIL # # The myorigin parameter specifies the domain that locally-posted # mail appears to come from. The default is to append $myhostname, # which is fine for small sites. If you run a domain with multiple # machines, you should (1) change this to $mydomain and (2) set up # a domain-wide alias database that aliases each user to # user@that.users.mailhost. # # For the sake of consistency between sender and recipient addresses, # myorigin also specifies the default domain name that is appended # to recipient addresses that have no @domain part. # #myorigin = $myhostname #myorigin = $mydomain myorigin = $mydomain ← 追加 # RECEIVING MAIL # The inet_interfaces parameter specifies the network interface # addresses that this mail system receives mail on. By default, # the software claims all active interfaces on the machine. The # parameter also controls delivery of mail to user@[ip.address]. # # See also the proxy_interfaces parameter, for network addresses that # are forwarded to us via a proxy or network address translator. # # Note: you need to stop/start Postfix when this parameter changes. # #inet_interfaces = all #inet_interfaces = $myhostname #inet_interfaces = $myhostname, localhost inet_interfaces = localhost ← 確認(ローカルからの送信しかしない) # Enable IPv4, and IPv6 if supported inet_protocols = all (〜略〜) # DELIVERY TO MAILBOX # # The home_mailbox parameter specifies the optional pathname of a # mailbox file relative to a user's home directory. The default # mailbox file is /var/spool/mail/user or /var/mail/user. Specify # "Maildir/" for qmail-style delivery (the / is required). # #home_mailbox = Mailbox #home_mailbox = Maildir/ home_mailbox = Maildir/ ← 追加 (〜略〜) # SHOW SOFTWARE VERSION OR NOT # # The smtpd_banner parameter specifies the text that follows the 220 # code in the SMTP server's greeting banner. Some people like to see # the mail version advertised. By default, Postfix shows no version. # # You MUST specify $myhostname at the start of the text. That is an # RFC requirement. Postfix itself does not care. # #smtpd_banner = $myhostname ESMTP $mail_name #smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) smtpd_banner = $myhostname ESMTP unknown ← 追加(メールサーバーソフト名の隠蔽) (〜略〜)
# vi /etc/postfix/master.cf
smtp inet n - n - - smtpd ↓コメントアウト #smtp inet n - n - - smtpd
# mkdir -p /etc/skel/Maildir/{new,cur,tmp} # chmod -R 700 /etc/skel/Maildir/
# alternatives --config mtaCentOS6.4では1つしかない。
1 プログラムがあり 'mta' を提供します。 選択 コマンド ----------------------------------------------- *+ 1 /usr/sbin/sendmail.postfix Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:
# /etc/rc.d/init.d/postfix start postfix を起動中: [ OK ]
# mail -s "[$HOSTNAME] TEST" hoge@mydomain.com Sample message . ← .(ドット)で本文終了hoge@mydomain.com にメールが届けば完了。
# # chkconfig postfix on
# mail -s "(件名)" メールアドレスコマンド入力後にメール本文を入力し、改行+「.」(ドット)により入力を終了する。
# mail -s "Test" hoge@mydomain.com Sample message ← 本文 . ← 入力終了
echo "Sample message" | mail -s "Test" hoge@mydomain.com