Subject: bug#47330: [PATCH] Add options to save sent mail

From: "Andrea G. Monaco" <[email-masked]>
Date: Mon, 22 Mar 2021 23:04:56 +0100

I think this might be useful, for me it is.

Add options to save sent mail

* lisp/gnus/message.el: add defcustoms message-save-sent-mail and
  message-sent-mail-directory
  (message-send): save sent mail if message-save-sent-mail is set

diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 1e0362a3bf..e159d50ebe 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -469,6 +469,18 @@ message-confirm-send
   :link '(custom-manual "(message)Sending Variables")
   :type 'boolean)
 
+(defcustom message-save-sent-mail nil
+  "When non-nil, save messages after successfully sending them, after running message-sent-hook."
+  :group 'message-sending
+  :group 'message-mail
+  :type 'boolean)
+
+(defcustom message-sent-mail-directory (concat message-directory "sent/")
+  "Directory where sent mail is saved, when message-save-sent-mail is set."
+  :group 'message-sending
+  :group 'message-mail
+  :type 'directory)
+
 (defcustom message-generate-new-buffers 'unsent
   "Say whether to create a new message buffer to compose a message.
 Valid values include:
@@ -4364,7 +4376,7 @@ message-send
       (message-do-fcc)
       (save-excursion
        (run-hooks 'message-sent-hook))
-      (message "Sending...done")
+      (message "Sending... done")
       ;; Do ecomplete address snarfing.
       (when (and (message-mail-alias-type-p 'ecomplete)
                 (not message-inhibit-ecomplete))
@@ -4373,6 +4385,9 @@ message-send
       (set-buffer-modified-p nil)
       (delete-auto-save-file-if-necessary t)
       (message-disassociate-draft)
+      ;; Save mail if the user wishes so
+      (if message-save-sent-mail
+          (write-file (concat message-sent-mail-directory (format-time-string "%Y%m%d-%H%M%S"))))
       ;; Delete other mail buffers and stuff.
       (message-do-send-housekeeping)
       (message-do-actions message-send-actions)