4 ;; Yet another mail interface. this for the rmail system to provide
5 ;; the missing sendmail interface on systems without /usr/lib/sendmail,
6 ;; but with /usr/uci/post.
8 ;; created by: Gary Delp <delp at huey.Udel.Edu>
9 ;; Mon Jan 13 14:45:12 1986
13 ;; (setq send-mail-function 'post-mail-send-it)
15 (defun post-mail-send-it ()
16 "The MH -post interface for `rmail-mail' to call.
17 To use it, include \"(setq send-mail-function 'post-mail-send-it)\" in
19 (let ((errbuf (if mail-interactive
20 (generate-new-buffer " post-mail errors")
22 (temfile "/tmp/,rpost")
23 (tembuf (generate-new-buffer " post-mail temp"))
24 (case-fold-search nil
)
26 (mailbuf (current-buffer)))
31 (insert-buffer-substring mailbuf
)
32 (goto-char (point-max))
33 ;; require one newline at the end.
34 (or (= (preceding-char) ?
\n)
36 ;; Change header-delimiter to be what post-mail expects.
37 (goto-char (point-min))
38 (search-forward (concat "\n" mail-header-separator
"\n"))
39 (replace-match "\n\n")
41 (setq delimline
(point-marker))
43 (expand-mail-aliases (point-min) delimline
))
44 (goto-char (point-min))
45 ;; ignore any blank lines in the header
46 (while (and (re-search-forward "\n\n\n*" delimline t
)
47 (< (point) delimline
))
49 ;; Find and handle any FCC fields.
50 (let ((case-fold-search t
))
51 (goto-char (point-min))
52 (if (re-search-forward "^FCC:" delimline t
)
53 (mail-do-fcc delimline
))
54 ;; If there is a From and no Sender, put it a Sender.
55 (goto-char (point-min))
56 (and (re-search-forward "^From:" delimline t
)
58 (goto-char (point-min))
59 (re-search-forward "^Sender:" delimline t
)))
62 (insert "Sender: " (user-login-name) "\n")))
63 ;; don't send out a blank subject line
64 (goto-char (point-min))
65 (if (re-search-forward "^Subject:[ \t]*\n" delimline t
)
71 (write-file (setq temfile
(make-temp-name temfile
)))
72 (set-file-modes temfile
384)
74 (append (list (if (boundp 'post-mail-program
)
76 "/usr/uci/lib/mh/post")
79 (if mail-interactive
'("-watch") '("-nowatch"))
84 (goto-char (point-min))
85 (while (re-search-forward "\n\n* *" nil t
)
87 (if (not (zerop (buffer-size)))
88 (error "Sending...failed to %s"
89 (buffer-substring (point-min) (point-max)))))))
92 (switch-to-buffer errbuf
)))))