Function: mh-send-letter

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

Signature

(mh-send-letter &optional ARG)

Documentation

Save draft and send message.

When you are all through editing a message, you send it with this command. You can give a prefix argument ARG to monitor the first stage of the delivery; this output can be found in a buffer called "*MH-E Mail Delivery*".

The hook mh-before-send-letter-hook is run at the beginning of this command. For example, if you want to check your spelling in your message before sending, add the function ispell-message.

Unless mh-insert-auto-fields had previously been called manually, the function mh-insert-auto-fields is called to insert fields based upon the recipients. If fields are added, you are given a chance to see and to confirm these fields before the message is actually sent. You can do away with this confirmation by turning off the option mh-auto-fields-prompt-flag.

In case the MH "send" program is installed under a different name, use mh-send-prog to tell MH-E the name.

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
;;;###autoload
(defun mh-send-letter (&optional arg)
  "Save draft and send message.

When you are all through editing a message, you send it with this
command. You can give a prefix argument ARG to monitor the first stage
of the delivery; this output can be found in a buffer called \"*MH-E
Mail Delivery*\".

The hook `mh-before-send-letter-hook' is run at the beginning of
this command. For example, if you want to check your spelling in
your message before sending, add the function `ispell-message'.

Unless `mh-insert-auto-fields' had previously been called
manually, the function `mh-insert-auto-fields' is called to
insert fields based upon the recipients. If fields are added, you
are given a chance to see and to confirm these fields before the
message is actually sent. You can do away with this confirmation
by turning off the option `mh-auto-fields-prompt-flag'.

In case the MH \"send\" program is installed under a different name,
use `mh-send-prog' to tell MH-E the name.

The hook `mh-annotate-msg-hook' is run after annotating the
message and scan line."
  (interactive "P")
  (run-hooks 'mh-before-send-letter-hook)
  (if (and (mh-insert-auto-fields t)
           mh-auto-fields-prompt-flag
           (goto-char (point-min)))
      (if (not (y-or-n-p "Auto fields inserted, send? "))
          (error "Send aborted")))
  (cond ((mh-mh-directive-present-p)
         (mh-mh-to-mime))
        ((or (mh-mml-tag-present-p) (not (mh-ascii-buffer-p)))
         (mh-mml-to-mime)))
  (save-buffer)
  (message "Sending...")
  (let ((draft-buffer (current-buffer))
        (file-name buffer-file-name)
        (config mh-previous-window-config)
        (coding-system-for-write (select-message-coding-system)))
    ;; Older versions of spost do not support -msgid and -mime.
    (unless mh-send-uses-spost-flag
      ;; Adding a Message-ID field looks good, makes it easier to search for
      ;; message in your +outbox, and best of all doesn't break threading for
      ;; the recipient if you reply to a message in your +outbox.
      (setq mh-send-args (concat "-msgid " mh-send-args))
      ;; The default Bcc encapsulation will make a MIME message unreadable.
      ;; With nmh use the -mime arg to prevent this.
      (if (and (mh-variant-p 'nmh)
               (mh-goto-header-field "Bcc:")
               (mh-goto-header-field "Content-Type:"))
          (setq mh-send-args (concat "-mime " mh-send-args))))
    (cond (arg
           (pop-to-buffer mh-mail-delivery-buffer)
           (erase-buffer)
           (mh-exec-cmd-output mh-send-prog t
                               "-nodraftfolder" "-watch" "-nopush"
                               (split-string mh-send-args) file-name)
           (goto-char (point-max))      ; show the interesting part
           (recenter -1)
           (set-buffer draft-buffer))   ; for annotation below
          (t
           (mh-exec-cmd-daemon mh-send-prog nil
                               "-nodraftfolder" "-noverbose"
                               (split-string mh-send-args) file-name)))
    (if mh-annotate-char
        (mh-annotate-msg mh-sent-from-msg
                         mh-sent-from-folder
                         mh-annotate-char
                         "-component" mh-annotate-field
                         "-text" (format "\"%s %s\""
                                         (mh-get-header-field "To:")
                                         (mh-get-header-field "Cc:"))))

    (cond ((or (not arg)
               (y-or-n-p "Kill draft buffer? "))
           (kill-buffer draft-buffer)
           (if config
               (set-window-configuration config))))
    (if arg
        (message "Sending...done")
      (message "Sending...backgrounded"))))