Function: message-resend

message-resend is an autoloaded, interactive and byte-compiled function defined in message.el.gz.

Signature

(message-resend ADDRESS)

Documentation

Resend the current article to ADDRESS.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/message.el.gz
;;;###autoload
(defun message-resend (address)
  "Resend the current article to ADDRESS."
  (interactive
   (list (message-read-from-minibuffer "Resend message to: ")))
  (message "Resending message to %s..." address)
  (save-excursion
    (let ((cur (current-buffer))
	  gcc beg)
      ;; We first set up a normal mail buffer.
      (unless (message-mail-user-agent)
	(set-buffer (gnus-get-buffer-create " *message resend*"))
	(let ((inhibit-read-only t))
	  (erase-buffer)))
      (let ((message-this-is-mail t)
	    message-generate-hashcash
	    message-setup-hook)
	(message-setup `((To . ,address))))
      ;; Insert our usual headers.
      (message-generate-headers '(From Date To Message-ID))
      (message-narrow-to-headers)
      (when (setq gcc (mail-fetch-field "gcc" nil t))
	(message-remove-header "gcc"))
      ;; Remove X-Draft-From header etc.
      (message-remove-header message-ignored-mail-headers t)
      ;; Rename them all to "Resent-*".
      (goto-char (point-min))
      (while (re-search-forward "^[A-Za-z]" nil t)
	(forward-char -1)
	(insert "Resent-"))
      (widen)
      (forward-line)
      (let ((inhibit-read-only t))
	(delete-region (point) (point-max)))
      (setq beg (point))
      ;; Insert the message to be resent.
      (insert-buffer-substring cur)
      (goto-char (point-min))
      (search-forward "\n\n")
      (forward-char -1)
      (save-restriction
	(narrow-to-region beg (point))
	(message-remove-header message-ignored-resent-headers t)
	(goto-char (point-max)))
      (insert mail-header-separator)
      ;; Rename all old ("Also-")Resent headers.
      (while (re-search-backward "^\\(Also-\\)*Resent-" beg t)
	(beginning-of-line)
	(insert "Also-"))
      ;; Quote any "From " lines at the beginning.
      (goto-char beg)
      (when (looking-at "From ")
	(replace-match "X-From-Line: "))
      ;; Send it.
      (let ((message-inhibit-body-encoding
	     ;; Don't do any further encoding if it looks like the
	     ;; message has already been encoded.
	     (let ((case-fold-search t))
	       (re-search-forward "^mime-version:" nil t)))
	    (message-inhibit-ecomplete t)
	    ;; We don't want smtpmail.el to encode anything, either.
	    (sendmail-coding-system 'raw-text)
	    (select-safe-coding-system-function nil)
	    message-required-mail-headers
	    message-generate-hashcash
	    rfc2047-encode-encoded-words
            ;; If `message-sendmail-envelope-from' is `header' then
            ;; the envelope-from will be the original sender's
            ;; address, not the resender's.  But when resending, the
            ;; envelope-from should be the resender's address.  Defuse
            ;; that particular case.
            (message-sendmail-envelope-from
             (and (not (and (eq message-sendmail-envelope-from
                                'obey-mail-envelope-from)
                            (eq mail-envelope-from 'header)))
                  (not (eq message-sendmail-envelope-from 'header))
                  message-sendmail-envelope-from)))
	(message-send-mail))
      (when gcc
	(message-goto-eoh)
	(insert "Gcc: " gcc "\n"))
      (run-hooks 'message-sent-hook)
      (kill-buffer (current-buffer)))
    (message "Resending message to %s...done" address)))