Function: mh-redistribute

mh-redistribute is an autoloaded, interactive and byte-compiled function defined in mh-comp.el.gz.

Signature

(mh-redistribute TO CC IDENTITY &optional MESSAGE)

Documentation

Redistribute a message.

This command is similar in function to forwarding mail, but it does not allow you to edit the message, nor does it add your name to the "From" header field. It appears to the recipient as if the message had come from the original sender. When you run this command, you are prompted for the TO and CC recipients. You are also prompted for the sending IDENTITY to use. The default MESSAGE is the current message.

Also investigate the command M-x mh-edit-again (mh-edit-again) for another way to redistribute messages.

See also mh-redist-full-contents-flag.

The hook mh-annotate-msg-hook is run after annotating the message and scan line.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-comp.el.gz
;;;###mh-autoload
(defun mh-redistribute (to cc identity &optional message)
  "Redistribute a message.

This command is similar in function to forwarding mail, but it
does not allow you to edit the message, nor does it add your name
to the \"From\" header field. It appears to the recipient as if
the message had come from the original sender. When you run this
command, you are prompted for the TO and CC recipients. You are
also prompted for the sending IDENTITY to use. The default
MESSAGE is the current message.

Also investigate the command \\[mh-edit-again] for another way to
redistribute messages.

See also `mh-redist-full-contents-flag'.

The hook `mh-annotate-msg-hook' is run after annotating the
message and scan line."
  (interactive (list (mh-read-address "Redist-To: ")
                     (mh-read-address "Redist-Cc: ")
                     (if mh-identity-list
                         (mh-select-identity mh-identity-default)
                       nil)
                     (mh-get-msg-num t)))
  (or message
      (setq message (mh-get-msg-num t)))
  (save-window-excursion
    (let ((folder mh-current-folder)
          (draft (mh-read-draft "redistribution"
                                (if mh-redist-full-contents-flag
                                    (mh-msg-filename message)
                                  nil)
                                nil))
          (from (mh-identity-field identity "From"))
          (fcc  (mh-identity-field identity "Fcc"))
          (bcc  (mh-identity-field identity "Bcc"))
          comp-fcc comp-to comp-cc comp-bcc)
      (if mh-redist-full-contents-flag
          (mh-clean-msg-header
           (point-min)
           "^Message-Id:\\|^Received:\\|^Return-Path:\\|^Date:\\|^Resent-.*:"
           nil))
      ;; Read fields from the distcomps file and put them in our
      ;; draft. For "To", "Cc", "Bcc", and "Fcc", multiple headers are
      ;; combined into a single header with comma-separated entries.
      ;; For "From", the first value wins, with the identity's "From"
      ;; trumping anything in the distcomps file.
      (let ((components-file (mh-bare-components mh-dist-formfile)))
        (mapc
         (lambda (header-field)
           (let ((field (car header-field))
                 (value (cdr header-field))
                 (case-fold-search t))
             (cond
              ((string-match field "^Resent-Fcc$")
               (setq comp-fcc value))
              ((string-match field "^Resent-From$")
               (or from
                   (setq from value)))
              ((string-match field "^Resent-To$")
               (setq comp-to value))
              ((string-match field "^Resent-Cc$")
               (setq comp-cc value))
              ((string-match field "^Resent-Bcc$")
               (setq comp-bcc value))
              ((string-match field "^Resent-.*$")
               (mh-insert-fields field value)))))
         (mh-components-to-list components-file))
        (delete-file components-file))
      (mh-insert-fields "Resent-To:" (mapconcat #'identity (list to comp-to)
                                                ", ")
                        "Resent-Cc:" (mapconcat #'identity (list cc comp-cc)
                                                ", ")
                        "Resent-Fcc:" (mapconcat #'identity (list fcc comp-fcc)
                                                 ", ")
                        "Resent-Bcc:" (mapconcat #'identity (list bcc comp-bcc)
                                                 ", ")
                        "Resent-From:" from)
      (save-buffer)
      (message "Redistributing...")
      (let ((env "mhdist=1"))
        ;; Setup environment...
        (setq env (concat env " mhaltmsg="
                          (if mh-redist-full-contents-flag
                              buffer-file-name
                            (mh-msg-filename message folder))))
        (unless mh-redist-full-contents-flag
          (setq env (concat env " mhannotate=1")))
        ;; Redistribute...
        (if mh-redist-background
            (mh-exec-cmd-env-daemon env mh-send-prog nil buffer-file-name)
          (mh-exec-cmd-error env mh-send-prog "-push" buffer-file-name))
        ;; Annotate...
        (mh-annotate-msg message folder mh-note-dist
                         "-component" "Resent:"
                         "-text" (format "\"To: %s Cc: %s From: %s\""
                                         to cc from)))
      (kill-buffer draft)
      (message "Redistributing...done"))))