6.5 Archived Messages

Gnus provides a few different methods for storing the mail and news you send. The default method is to use the archive virtual server to store the messages. If you want to disable this completely, the gnus-message-archive-group variable should be nil. The default is "sent.%Y-%m", which gives you one archive group per month.

For archiving interesting messages in a group you read, see the B c (gnus-summary-copy-article) command (see Mail Group Commands).

gnus-message-archive-method says what virtual server Gnus is to use to store sent messages. The default is "archive", and when actually being used it is expanded into:

(nnfolder "archive"
          (nnfolder-directory   "~/Mail/archive")
          (nnfolder-active-file "~/Mail/archive/active")
          (nnfolder-get-new-mail nil)
          (nnfolder-inhibit-expiry t))

Note: a server like this is saved in the ~/.newsrc.eld file first so that it may be used as a real method of the server which is named "archive" (that is, for the case where gnus-message-archive-method is set to "archive") ever since. If it once has been saved, it will never be updated by default even if you change the value of gnus-message-archive-method afterward. Therefore, the server "archive" doesn’t necessarily mean the nnfolder server like this at all times. If you want the saved method to reflect always the value of gnus-message-archive-method, set the gnus-update-message-archive-method variable to a non-nil value. The default value of this variable is nil.

You can, however, use any mail select method (nnml, nnmbox, etc.). nnfolder is a quite likable select method for doing this sort of thing, though. If you don’t like the default directory chosen, you could say something like:

(setq gnus-message-archive-method
      '(nnfolder "archive"
                 (nnfolder-inhibit-expiry t)
                 (nnfolder-active-file "~/News/sent-mail/active")
                 (nnfolder-directory "~/News/sent-mail/")))

Gnus will insert Gcc headers in all outgoing messages that point to one or more group(s) on that server. Which group to use is determined by the gnus-message-archive-group variable.

This variable can be used to do the following:

a string

Messages will be saved in that group.

Note that you can include a select method in the group name, then the message will not be stored in the select method given by gnus-message-archive-method, but in the select method specified by the group name, instead. Suppose gnus-message-archive-method has the default value shown above. Then setting gnus-message-archive-group to "foo" means that outgoing messages are stored in ‘nnfolder+archive:foo’, but if you use the value "nnml:foo", then outgoing messages will be stored in ‘nnml:foo’.

a list of strings

Messages will be saved in all those groups.

an alist of regexps, functions and forms

When a key “matches”, the result is used.

nil

No message archiving will take place.

Let’s illustrate:

Just saving to a single group called ‘MisK’:

(setq gnus-message-archive-group "MisK")

Saving to two groups, ‘MisK’ and ‘safe’:

(setq gnus-message-archive-group '("MisK" "safe"))

Save to different groups based on what group you are in:

(setq gnus-message-archive-group
      '(("^alt" "sent-to-alt")
        ("mail" "sent-to-mail")
        (".*" "sent-to-misc")))

More complex stuff:

(setq gnus-message-archive-group
      '((if (message-news-p)
            "misc-news"
          "misc-mail")))

How about storing all news messages in one file, but storing all mail messages in one file per month:

(setq gnus-message-archive-group
      '((if (message-news-p)
            "misc-news"
          (concat "mail." (format-time-string "%Y-%m")))))

Now, when you send a message off, it will be stored in the appropriate group. (If you want to disable storing for just one particular message, you can just remove the Gcc header that has been inserted.) The archive group will appear in the group buffer the next time you start Gnus, or the next time you press F in the group buffer. You can enter it and read the articles in it just like you’d read any other group. If the group gets really big and annoying, you can simply rename if (using G r in the group buffer) to something nice—‘misc-mail-september-1995’, or whatever. New messages will continue to be stored in the old (now empty) group.

gnus-gcc-mark-as-read

If non-nil, automatically mark Gcc articles as read.

gnus-gcc-externalize-attachments

If nil, attach files as normal parts in Gcc copies; if a regexp and matches the Gcc group name, attach files as external parts; if it is all, attach local files as external parts; if it is other non-nil, the behavior is the same as all, but it may be changed in the future.

gnus-gcc-self-resent-messages

Like the gcc-self group parameter, applied only for unmodified messages that gnus-summary-resend-message (see Summary Mail Commands) resends. Non-nil value of this variable takes precedence over any existing Gcc header.

If this is none, no Gcc copy will be made. If this is t, messages resent will be Gcc copied to the current group. If this is a string, it specifies a group to which resent messages will be Gcc copied. If this is nil, Gcc will be done according to existing Gcc header(s), if any. If this is no-gcc-self, that is the default, resent messages will be Gcc copied to groups that existing Gcc header specifies, except for the current group.

gnus-gcc-pre-body-encode-hook
gnus-gcc-post-body-encode-hook

These hooks are run before/after encoding the message body of the Gcc copy of a sent message. The current buffer (when the hook is run) contains the message including the message header. Changes made to the message will only affect the Gcc copy, but not the original message. You can use these hooks to edit the copy (and influence subsequent transformations), e.g., remove MML secure tags (see Signing and encrypting).