Next: , Up: Dynamic folders   [Contents]

10.1 Smart refiling

When refiling messages, perhaps to archive them, it can be useful to have different target folders for different messages, based on some property of those message – smart refiling.

To accomplish this, we can set the refiling folder (mu4e-refile-folder) to a function that returns the actual refiling folder for the particular message. An example should clarify this:

(setq mu4e-refile-folder
  (lambda (msg)
      ;; messages to the mu mailing list go to the /mu folder
      ((mu4e-message-contact-field-matches msg :to
      ;; messages sent directly to me go to /archive
      ;; also `mu4e-user-mail-address-p' can be used
      ((mu4e-message-contact-field-matches msg :to "")
      ;; messages with football or soccer in the subject go to /football
      ((string-match "football\\|soccer"
         (mu4e-message-field msg :subject))
      ;; messages sent by me go to the sent folder
         (lambda (addr)
           (mu4e-message-contact-field-matches msg :from addr))
      ;; everything else goes to /archive
      ;; important to have a catch-all at the end!
      (t  "/archive"))))

This can be very powerful; you can select some messages in the headers view, then press r, and have them all marked for refiling to their particular folders.

Some notes:



a property list describing a message

Next: , Up: Dynamic folders   [Contents]