Function: message-send-mail-with-sendmail
message-send-mail-with-sendmail is a byte-compiled function defined in
message.el.gz.
Signature
(message-send-mail-with-sendmail)
Documentation
Send off the prepared buffer with sendmail.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/message.el.gz
(defun message-send-mail-with-sendmail ()
"Send off the prepared buffer with sendmail."
(require 'sendmail)
(let ((errbuf (if message-interactive
(message-generate-new-buffer-clone-locals
" sendmail errors")
0))
resend-to-addresses delimline)
(unwind-protect
(progn
(let ((case-fold-search t))
(save-restriction
(message-narrow-to-headers)
(setq resend-to-addresses (message-fetch-field "resent-to")))
;; Change header-delimiter to be what sendmail expects.
(goto-char (point-min))
(re-search-forward
(concat "^" (regexp-quote mail-header-separator) "\n"))
(replace-match "\n")
(backward-char 1)
(setq delimline (point-marker))
(run-hooks 'message-send-mail-hook)
;; Insert an extra newline if we need it to work around
;; Sun's bug that swallows newlines.
(goto-char (1+ delimline))
(when (eval message-mailer-swallows-blank-line t)
(newline))
(when message-interactive
(with-current-buffer errbuf
(erase-buffer))))
(let* ((default-directory "/")
(coding-system-for-write message-send-coding-system)
(cpr (apply
#'call-process-region
(append
(list (point-min) (point-max) sendmail-program
nil errbuf nil "-oi")
message-sendmail-extra-arguments
;; Always specify who from,
;; since some systems have broken sendmails.
;; But some systems are more broken with -f, so
;; we'll let users override this.
(and (null message-sendmail-f-is-evil)
(list "-f" (message-sendmail-envelope-from)))
;; These mean "report errors by mail"
;; and "deliver in background".
(if (null message-interactive) '("-oem" "-odb"))
;; Get the addresses from the message
;; unless this is a resend.
;; We must not do that for a resend
;; because we would find the original addresses.
;; For a resend, include the specific addresses.
(if resend-to-addresses
(list resend-to-addresses)
'("-t"))))))
(unless (or (null cpr) (and (numberp cpr) (zerop cpr)))
(when errbuf
(pop-to-buffer errbuf)
(setq errbuf nil))
(error "Sending...failed with exit value %d" cpr)))
(when message-interactive
(with-current-buffer errbuf
(goto-char (point-min))
(while (re-search-forward "\n+ *" nil t)
(replace-match "; "))
(if (not (zerop (buffer-size)))
(error "Sending...failed to %s"
(buffer-string))))))
(when (buffer-live-p errbuf)
(kill-buffer errbuf)))))