Résumé : Add hook for colorizing multiply-quoted e-mails.
> = colorizing multiply-quoted lines =
> If you want to have the lines of an e-mail colorized differently depending on how many levels of quoting (instead of just one color for all quoted text), you can use this hook (after you've defined the faces):
> (add-hook 'message-mode-hook
> (lambda ()
> (font-lock-add-keywords nil
> '(("^[ \t]*>[ \t]*>[ \t]*>.*$"
> (0 'message-multiply-quoted-text-face))
> ("^[ \t]*>[ \t]*>.*$"
> (0 'message-double-quoted-text-face))))))
> This would also work in mail-mode, with the appropriate changes.
Mode used by Gnus to edit mail messages
Message mode is an alternative to mail mode for composing and sending messages inside emacs. This is part of the standard emacs distribution, and is the preferred mode used by gnus for composing and sending messages. It can be used independently from gnus however, and has its own manual. This manual can be browsed online at  or directly from inside emacs (
C-h i m message RET).
Message mode handles MIME attachments. This is the main benefit over the default mail mode.
Using message mode instead of mail mode for sending mail is as simple as putting the following in the InitFile
(setq mail-user-agent 'message-user-agent)
The basic settings are specified as in mail mode
(setq user-mail-address "firstname.lastname@example.org" user-full-name "me myself and I")
The standard method on the system is used by default for sending mail. You may want however to use some specific smtp server, say smtp.somewhere.edu
(setq smtpmail-smtp-server "smtp.somewhere.edu") (message-send-mail-function 'message-smtpmail-send-it)
Here are some other configuration tweaks that may be useful
;; use the default input method in message mode (add-hook 'message-mode-hook 'toggle-input-method)
;; report problems with the smtp server (setq smtpmail-debug-info t)
;; add Cc and Bcc headers to the message buffer (setq message-default-mail-headers "Cc: \nBcc: \n")
;; postponed message is put in the following draft file (setq message-auto-save-directory "~/Mail/drafts")
C-x m to bring a message buffer. The following basic shortcuts becomes available
C-c C-c send the message and exit the message buffer C-c C-a add an attachment C-c C-k cancel the message
Here are some other shortcuts available in message mode
C-c C-d postpone the message C-c C-s send the message but don't exit the message buffer C-c C-b go to the start of the message C-c C-z kill text from point until end of buffer
C-h m to browse the full list.
In order to go back to a postponed message, just open the \*message\* buffer. This buffer has been saved in the directory specified above:
~/Mail/drafts/\*message\*. In case the message is from a previous emacs session, you may have to put it manually in message mode by typing
M-x message-mode. There is only support for saving a single postponed message. For a better handling of postponed messages, please consider using message mode from gnus.
Finally, recall that you can activate mail adresses in any buffer at any time by typing
M-x goto-address. Cliking on a mail address will then bring a message buffer.
There is an additional mode that allows the emacs buffer to create a outlook message. This is described in MessageOutlook
In order to attach a full folder content to a message, one may prefers to create a custom lisp function to do it. Then all you have to do is to call it, and even better to bind it to a dedicated keyboard shortcut. An example of such lisp function (usable only on *nix computers) may looks like:
(defun message-attach-all-files-from-folder(&optional disposition dir-to-attach) "create the mml code to attach all files found in a given directory" (interactive) (if (eq disposition nil) (setq disposition (completing-read "Enter default disposition to use: " '(("attachment" 1) ("inline" 2)) nil t))) (if (eq dir-to-attach nil) (setq dir-to-attach (read-directory-name "Select a folder to attach: "))) (if (not (string-match "/$" dir-to-attach)) (setq dir-to-attach (concat dir-to-attach "/"))) (dolist (file (directory-files dir-to-attach)) (when (and (not (string= "." file)) (not (string= ".." file))) (let (full-file-path mime-type) (setq full-file-path (concat dir-to-attach file)) (if (file-readable-p full-file-path) (if (file-directory-p full-file-path) (message-attach-all-files-from-folder disposition full-file-path) (setq mime-type (substring (shell-command-to-string (concat "file --mime-type --brief " (shell-quote-argument (expand-file-name full-file-path)))) 0 -1)) (insert-string (concat "<#part type=\"" mime-type "\" filename=\"" full-file-path "\" disposition=" disposition ">\n")) ) ) ) ) ) )
If you want to have the lines of an e-mail colorized differently depending on how many levels of quoting (instead of just one color for all quoted text), you can use this hook (after you’ve defined the faces):
(add-hook 'message-mode-hook (lambda () (font-lock-add-keywords nil '(("^[ \t]*>[ \t]*>[ \t]*>.*$" (0 'message-multiply-quoted-text-face)) ("^[ \t]*>[ \t]*>.*$" (0 'message-double-quoted-text-face))))))
This would also work in mail-mode, with the appropriate changes.