1 ;;; mailpost.el --- RMAIL coupler to /usr/uci/post mailer
3 ;; Author: Gary Delp <delp@huey.Udel.Edu>
5 ;; Created: 13 Jan 1986
6 ;; Last-Modified: 30 May 1992
9 ;; This is in the public domain
10 ;; since Delp distributed it without a copyright notice in 1986.
14 ;; Yet another mail interface. this for the rmail system to provide
15 ;; the missing sendmail interface on systems without /usr/lib/sendmail,
16 ;; but with /usr/uci/post.
20 ;; (setq send-mail-function 'post-mail-send-it)
22 (defun post-mail-send-it ()
23 "The MH -post interface for `rmail-mail' to call.
24 To use it, include \"(setq send-mail-function 'post-mail-send-it)\" in
26 (let ((errbuf (if mail-interactive
27 (generate-new-buffer " post-mail errors")
29 (temfile "/tmp/,rpost")
30 (tembuf (generate-new-buffer " post-mail temp"))
31 (case-fold-search nil
)
33 (mailbuf (current-buffer)))
38 (insert-buffer-substring mailbuf
)
39 (goto-char (point-max))
40 ;; require one newline at the end.
41 (or (= (preceding-char) ?
\n)
43 ;; Change header-delimiter to be what post-mail expects.
44 (goto-char (point-min))
45 (search-forward (concat "\n" mail-header-separator
"\n"))
46 (replace-match "\n\n")
48 (setq delimline
(point-marker))
50 (expand-mail-aliases (point-min) delimline
))
51 (goto-char (point-min))
52 ;; ignore any blank lines in the header
53 (while (and (re-search-forward "\n\n\n*" delimline t
)
54 (< (point) delimline
))
56 ;; Find and handle any FCC fields.
57 (let ((case-fold-search t
))
58 (goto-char (point-min))
59 (if (re-search-forward "^FCC:" delimline t
)
60 (mail-do-fcc delimline
))
61 ;; If there is a From and no Sender, put it a Sender.
62 (goto-char (point-min))
63 (and (re-search-forward "^From:" delimline t
)
65 (goto-char (point-min))
66 (re-search-forward "^Sender:" delimline t
)))
69 (insert "Sender: " (user-login-name) "\n")))
70 ;; don't send out a blank subject line
71 (goto-char (point-min))
72 (if (re-search-forward "^Subject:[ \t]*\n" delimline t
)
78 (write-file (setq temfile
(make-temp-name temfile
)))
79 (set-file-modes temfile
384)
81 (append (list (if (boundp 'post-mail-program
)
83 "/usr/uci/lib/mh/post")
86 (if mail-interactive
'("-watch") '("-nowatch"))
91 (goto-char (point-min))
92 (while (re-search-forward "\n\n* *" nil t
)
94 (if (not (zerop (buffer-size)))
95 (error "Sending...failed to %s"
96 (buffer-substring (point-min) (point-max)))))))
99 (switch-to-buffer errbuf
)))))
101 ;;; mailpost.el ends here