Emacs Message: save sent mails

How do you make Emacs Message (C-x m) conserve outward bound mails?

Exists a typical means to do this?

You can C-x C-s yet this mishandles and also very easy to neglect, besides, you can not be 100% it is the mail in fact sent out: you could have done some eleventh hour adjustments that you later on forgot.

Could this (save-buffer) be conjured up from a "send message" hook and also be automated? (Like text-mode-hook.) If so, what hook? (How do you get the hooks of a setting?)

BCC to on your own: not really classy?

FCC: appears to be ideal remedy, still, have to be automated, both conjuration and also an excellent documents name created.

2022-06-07 14:41:00
Source Share
Answers: 3

I make use of extra make complex remedy:

(defconst my-safe-filename-char-regex "[[:alnum:][email protected]]"
  "Safe file names.")

(defun my-clean-filename (filename)
   (lambda (ch) (or (when (string-match my-safe-filename-char-regex (char-to-string ch)) (char-to-string ch)) "-"))
   filename "") )

(defun my-message-save ()
  "Store message in `gnus-article-save-directory' after
successful sending. It is possible that mail rejected and I lost
it completely, this func save it for me."
  (unless (eq major-mode 'message-mode)
    (error "Attempt to call my-message-save in non message-mode buffer"))
  (make-directory gnus-article-save-directory t)
  (let ( (buf (current-buffer))
         (field-to (my-clean-filename (or (message-fetch-field "Newsgroups") (message-fetch-field "To"))))
         (field-subject (my-clean-filename (message-fetch-field "Subject")))
         file )
    (setq file (concat gnus-article-save-directory "/" (format-time-string "%F_%T") "_" field-to "_" field-subject))
    (with-temp-file file
      (insert-buffer buf)
      )) )
(add-hook 'message-sent-hook 'my-message-save)

Also keep in mind that I make use of message - sent out - hook as opposed to message - send - hook .

2022-06-07 20:49:06

Just obtained this to function. Place in .emacs:

(defun save-sent-mail ()
  (write-file (format-time-string "~/Mail/sent/%Y-%m-%d_%T") nil) )
(add-hook 'message-send-hook 'save-sent-mail)
2022-06-07 15:12:08

You can set the variable gcc-self to T for any kind of teams you intend to archive.

See its documents here. (or (gnus) Group Parameters)

EDIT: gcc-self isn't a" timeless" variable, you've to set it viagnus-parameter.

(setq gnus-parameters
         (gcc-self . t))))
2022-06-07 15:06:42