Solaris ユーザーズガイド (上級編)

/etc/aliases でメールエイリアスを設定する

/etc/aliases ファイルでメールエイリアスを設定する場合は、次の点に注意してください。

/etc/aliases に作成されるメールエイリアスの形式は、.mailrc の形式とは若干異なります。 /etc/aliases 内の各エイリアスは、次の形式でなければなりません。

/etc/aliases ファイルを変更するには、最初に root ユーザになる必要があります。root がパスワードで保護されている場合は、root のパスワードが必要です。

次のコマンドを入力してシステムの root ユーザになります。


$ su
Password:
#

root ユーザになるとコマンドプロンプトが変わることに注意してください。

次の例は、メールエイリアス softball@texas をデフォルトの /etc/aliases ファイルに追加する方法を示しています。


# vi /etc/aliases     
##
#Aliases can have any mix of upper and lower case on the left-
#hand side,
#but the right-hand side should be proper case (usually lower)
#
#>>>>>>>>>>The program “newaliases” will need to be run after
#>> NOTE>>this file is updated for any changes to
#>>>>>>>>>>show through to sendmail.
#
#@(#)aliases 1.10 89/01/20 SMI
##
# Following alias is required by the mail protocol, RFC 822
# Set it to the address of a HUMAN who deals with this system's
mail problems.
Postmaster: root

# Alias for mailer daemon; returned messages from our MAILER-
DAEMON
# should be routed to our local Postmaster.
MAILER-DAEMON: postmaster

# Aliases to handle mail to programs or files, eg news or vacation
# decode: “|/usr/bin/uudecode”
nobody: /dev/null

# Sample aliases:
# Alias for distribution list, members specified here:
#staff:wnj,mosher,sam,ecc,mckusick,sklower,olson,rwh@ernie

# Alias for distribution list, members specified elsewhere:
#keyboards: :include:/usr/jfarrell/keyboards.list

# Alias for a person, so they can receive mail by several names:
#epa:eric

#######################
# Local aliases below #
#######################
softball@texas: earl@woofer
tex@twister elmer@farmhouse
jane@freeway hank@fretful jj@walker sally@dakota steve@hardway
:wq         (vi を終了して /etc/aliases ファイルを保存する)
# exit      (root ユーザを終了する)
$

/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 と入力してマニュアルページを参照してください。