/etc/aliases ファイルでメールエイリアスを設定する場合は、次の点に注意してください。
/etc/aliases 内のメールエイリアスは公共用です。つまり、/etc/aliases 内で softball というメールエイリアスを設定すれば、全ユーザがこのエイリアスを利用して softball@your-machinename 宛てにメールを送信できます。
メールが送信されても、/etc/aliases 内のメールエイリアスは展開されません。たとえば、softball@machinename にメールを送信すると、エイリアスは展開されずそのままの形で受信されます。受信者側には、メールエイリアスの名前は分かりますが、そのエイリアスに含まれる他のユーザ名は分かりません。
/etc/aliases で作成されるメールエイリアスの形式は、.mailrc の形式とは若干異なります。/etc/aliases 内の各エイリアスは、次の形式でなければなりません。
メールエイリアスの名前とその後のコロン (:)
コンマで区切った受信者 (ログイン名とマシン名)。メールエイリアスの指定は複数行に渡ってもかまいません。
/etc/aliases ファイルを変更するには、最初に root ユーザになる必要があります。root がパスワードで保護されている場合は、root のパスワードが必要です。
次のコマンドを入力してシステムの root ユーザになります。
$ su Password: # |
root ユーザになるとコマンドプロンプトが変わることに注意してください。
次の例は、メールエイリアス softball@texas をデフォルトの /etc/aliases ファイルに追加する方法を示しています。
/etc/aliases ファイルの編集には任意のテキストエディタを使えます。上記の例は、vi エディタを使って編集する方法を示しています。vi に慣れていない場合は、第 6 章「vi エディタの使い方」を参照してください。
/etc/aliase ファイル内のポンド記号 (#) は、その後のテキストやエイリアスの例が注釈であることを示しています。先頭にポンド記号が付いた行の情報は、実際のエイリアスとしては処理されません。
意図的にエイリアスを使わないようにする場合以外は、このファイルに追加するエイリアスの前にはポンド記号を付けないでください。
/etc/aliases 内のエイリアスに含まれるユーザに対してメールを送信する場合は、そのエイリアスとマシン名をメールのアドレスとして指定します。たとえば、次のようにして送信します。
$ mail softball@texas Subject: Practice Today Let's meet at the diamond behind Building 4 after work tonight. Goodness knows we can use the practice for Saturday's game! Be there as early as you can. |
受信者は、次のようなメールを受け取ります。
To: softball@texas Subject: Practice Today Let's meet at the diamond behind Building 4 after work tonight. Goodness knows we can use the practice for Saturday's game! Be there as early as you can. |
To: の行が展開されていないことに注意してください。
/etc/aliases で設定されたメールエイリアスを使ってメールを送信する場合は、そのエイリアスが設定されているマシン名を必ず指定します。たとえば、マシン freeway 上で riders というメールエイリアスを設定した場合は、riders@freeway と指定してメールを送信しなければなりません。
.mailrc で設定されたメールエイリアスと /etc/aliases で設定されたメールエイリアスとの相違点を表 7-1 にまとめます。
表 7-1 .mailrc と /etc/aliases のメールエイリアス比較
|
.mailrc |
/etc/aliases |
---|---|---|
変更するために root になる必要性 |
なし |
あり |
メッセージを送信するときのアドレス |
alias |
alias@machinename |
To: 行と Cc: 行で受信者の一覧がつくか |
つく |
つかない |
名前をコンマで区切るか |
区切らない |
区切る |
すべての名前を 1 行内に記述するか |
する |
しない |
他のユーザがメールエイリアスを使えるか |
使えない |
使える |
メールエイリアスについての詳細は、システムプロンプトに対して man aliases または man addresses と入力してマニュアルページを参照してください。