Ubuntu Server 20.04.1 LTSでcronとかの結果メールが見たいのでメールサーバーとmailコマンドを導入です。
まずはサーバのpostfixの導入。
$ sudo apt install postfix
を実行するとPostfix Configurationとのことでメールサーバーの主な使用目的を尋ねられます。選択肢は以下の5つ。
Internet site: Mail is sent and received directly using SMTP. Internet with smarthost: Mail is received directly using SMTP or by running a utility such as fetchmail. Outgoing mail is sent using a smarthost. Satellite system: All mail is sent to another machine, called a 'smarthost', for delivery. Local only: The only delivered mail is the mail for local users. There is no network.
うちの目的ではLocal onlyを選択しました。ホスト名を入力してインストール完了。
あとrootへのメールも一般ユーザーで受け取りたいので/etc/aliasesを編集して
$ sudo newaliases
と実行。メールの確認にmailコマンドも必要ですので、
$ sudo apt install mailutils
にてインストールしました。rootへ簡単なテストメールを送信して、自分に届けば確認完了です。
mailコマンドでのメール送信ですがCtrl+Dで本文の入力完了になるんですね。今までは先頭にピリオドのみ入力でメール編集が終わってましたので、Ubuntuでの終了方法がわからず戸惑いました。