mailxに新しい電子メール通知を依頼するにはどうすればよいですか?

mailxに新しい電子メール通知を依頼するにはどうすればよいですか?

私のサーバーにmailxを設定しようとしています。あるサーバー(Raspbian)からYou have new mailメッセージ(または同様のもの)を含む新しいメールが届きました。他のコンピュータ(Raspbmc)はこの通知を受け取りませんでした。

どちらのコンピュータも~/.bashrc本質的に同じです。/etc/mail.rc後者のシステムには存在しませんが、前者には次の内容で存在します。

set ask askcc append dot save crt
ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via Delivered-To

編集する

SSH経由で接続することにも言及する必要があります。

提案通りここ、動作しているRaspbianサーバーから破損したRaspbmcサーバーにコピーし、ログアウトして再度ログインしようとしましたが、/etc/pam.d/sshd問題は解決しませんでした。このファイルには以下が含まれています。

# Print the status of the user's mailbox upon successful login.
session    optional     pam_mail.so standard noenv # [1]

最後に、接続時間が/var/mail/pi修正時間よりも早いことも確認しました。 (ファイルシステムはとにかくマウントされますnoatime。)

ベストアンサー1

AFAIKメール通知は、MAIL環境変数を設定することでbashに実装されているシェル機能であり、コマンドとはほとんど関係ありませんmailx。他のシェルでは、その機能が異なる場合があります。

私のRHELシステムの構成は/etc/profile次のとおりです。MAIL="/var/spool/mail/$USER"

設定すると、単純なecho $ MAILが表示されます。

一見すると、各メッセージは別々のファイルに保存されているMaildirではなく、mboxスタイルのメールボックスでのみ機能するようです。

Bashのマニュアルページから:

   MAIL   If  this  parameter is set to a file name and the MAILPATH vari-
          able is not set, bash informs the user of the arrival of mail in
          the specified file.
   MAILCHECK
          Specifies  how  often  (in  seconds)  bash checks for mail.  The
          default is 60 seconds.  When it is time to check for  mail,  the
          shell  does  so  before  displaying the primary prompt.  If this
          variable is unset, or set to  a  value  that  is  not  a  number
          greater than or equal to zero, the shell disables mail checking.
   MAILPATH
          A colon-separated list of file names to  be  checked  for  mail.
          The message to be printed when mail arrives in a particular file
          may be specified by separating the file name  from  the  message
          with a '?'.  When used in the text of the message, $_ expands to
          the name of the current mailfile.  Example:
          MAILPATH='/var/mail/bfox?"You  have  mail":~/shell-mail?"$_  has
          mail!"'
          Bash  supplies  a default value for this variable, but the loca-
          tion of the user mail files that it  uses  is  system  dependent
          (e.g., /var/mail/$USER).

同じシステムのcshマニュアルでは小文字で表示されます。

これ 郵便新しいメールを定期的に確認するシェル変数を設定できます。

そして

   mail    The names of the files or directories  to  check  for  incoming
           mail,  separated  by  whitespace,  and optionally preceded by a
           numeric word.  Before each prompt, if 10  minutes  have  passed
           since  the last check, the shell checks each file and says 'You
           have new mail.' (or, if mail contains multiple files, 'You have
           new  mail  in  name.')  if the filesize is greater than zero in
           size and has a modification time greater than its access  time.

           If  you  are  in  a  login shell, then no mail file is reported
           unless it has been  modified  after  the  time  the  shell  has
           started  up,  to  prevent  redundant notifications.  Most login
           programs will tell you whether or not you have  mail  when  you
           log in.

おすすめ記事