nnmail-read-incoming-hook

nnmail-read-incoming-hook is a variable defined in `nnmail.el'.
Its value is
nil

  • This variable may be risky if used as a file-local variable.

Documentation:
*Hook that will be run after the incoming mail has been transferred.
The incoming mail is moved from the specified spool file (which normally is
something like "/usr/spool/mail/$user") to the user's home
directory. This hook is called after the incoming mail box has been
emptied, and can be used to call any mail box programs you have
running ("xwatch", etc.)

E.g.:

(add-hook 'nnmail-read-incoming-hook
(lambda ()
(call-process "/local/bin/mailsend" nil nil nil
"read"
;; The incoming mail box file.
(expand-file-name (user-login-name)
rmail-spool-directory))))

If you have xwatch running, this will alert it that mail has been
read.

If you use `display-time', you could use something like this:

(add-hook 'nnmail-read-incoming-hook
(lambda ()
;; Update the displayed time, since that will clear out
;; the flag that says you have mail.
(when (eq (process-status "display-time") 'run)
(display-time-filter display-time-process ""))))

You can customize this variable.