annotate lisp/packages/feedmail.el @ 12:bcdc7deadc19 r19-15b7

Import from CVS: tag r19-15b7
author cvs
date Mon, 13 Aug 2007 08:48:16 +0200
parents 376386a54a3c
children 34a5b81f86ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; feedmail.el --- outbound mail handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Keywords: mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; From: William.J.Carpenter@hos1cad.att.com (Bill C)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; Subject: feedmail.el, patchlevel 2 [repost]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; Date: 8 Jun 91 22:23:00 GMT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; Organization: AT&T Bell Laboratories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; 5-may-92 jwz Conditionalized calling expand-mail-aliases, since that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; function doesn't exist in Lucid GNU Emacs or when using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; mail-abbrevs.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; Here's the latest version of feedmail.el, a replacement for parts of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; GNUemacs' sendmail.el (specifically, it's what handles your outgoing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; mail after you type C-c C-c in mail mode). (Sorry if you're seeing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; this a second time. Looks like my earlier attempt to post it didn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; get off the local machine.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; This version contains the following new things:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; * fix for handling default-case-fold-search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; * involve user-full-name in default from line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; * fix for my improper use of mail-strip-quoted-names when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; addresses contain a mix of "<>" and "()" styles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; * new feature allowing optional generation of Message-ID
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; feedmail.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; LCD record:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; feedmail|Bill Carpenter|william.j.carpenter@att.com|Outbound mail handling|91-05-24|2|feedmail.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; Written by Bill Carpenter <william.j.carpenter@att.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; original, 31 March 1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; patchlevel 1, 5 April 1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; patchlevel 2, 24 May 1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; As far as I'm concerned, anyone can do anything they want with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; this specific piece of code. No warranty or promise of support is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; offered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; This stuff does in elisp the stuff that used to be done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; by the separate program "fakemail" for processing outbound email.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; In other words, it takes over after you hit "C-c C-c" in mail mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; By appropriate setting of options, you can still use "fakemail",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; or you can even revert to sendmail (which is not too popular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; locally). See the variables at the top of the elisp for how to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;; achieve these effects:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; --- you can get one last look at the prepped outbound message and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;; be prompted for confirmation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; --- removes BCC: headers after getting address info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; --- does smart filling of TO: and CC: headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; --- processes FCC: lines and removes them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; --- empty headers are removed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; --- can force FROM: or SENDER: line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;; --- can generate a Message-ID line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; --- strips comments from address info (both "()" and "<>" are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; handled via a call to mail-strip-quoted-names); the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; comments are stripped in the simplified address list given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; to a subprocess, not in the headers in the mail itself
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; (they are left unchanged, modulo smart filling)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;; --- error info is pumped into a normal buffer instead of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; --- just before the optional prompt for confirmation, lets you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;; run a hook on the prepped message and simplified address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;; list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;; --- you can specify something other than /bin/mail for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;; subprocess
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;; After a few options below, you will find the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; feedmail-send-it. Everything after that function is just local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;; stuff for this file. There are two ways you can use the stuff in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;; this file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; (1) Put the contents of this file into sendmail.el and change the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; name of feedmail-send-it to sendmail-send-it, replacing that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;; function in sendmail.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;; (2) Save this file as feedmail.el somewhere on your elisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; loadpath; byte-compile it. Put the following lines somewhere in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; your ~/.emacs stuff:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; (setq send-mail-function 'feedmail-send-it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; (autoload 'feedmail-send-it "feedmail")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (defvar feedmail-confirm-outgoing nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 "*If non-nil, gives a y-or-n confirmation prompt after prepping,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 before sending mail.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defvar feedmail-nuke-bcc t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 "*Non-nil means get rid of the BCC: lines from the message header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 text before sending the mail. In any case, the BCC: lines do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 participate in the composed address list. You probably want to keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 them if you're using sendmail (see feedmail-buffer-eating-function).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (defvar feedmail-fill-to-cc t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 "*Non-nil means do smart filling (line-wrapping) of TO: and CC: header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 lines. If nil, the lines are left as-is. The filling is done after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 mail address alias expansion.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defvar feedmail-fill-to-cc-fill-column default-fill-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 "*Fill column used when wrapping mail TO: and CC: lines.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (defvar feedmail-nuke-empty-headers t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 "*If non-nil, headers with no contents are removed from the outgoing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 email. A completely empty SUBJECT: header is always removed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 regardless of the setting of this variable. The only time you would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 want them left in would be if you used some headers whose presence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 indicated something rather than their contents.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;; wjc sez: I think the use of the SENDER: line is pretty pointless,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;; but I left it in to be compatible with sendmail.el and because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;; maybe some distant mail system needs it. Really, though, if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;;; want a sender line in your mail, just put one in there and don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;; wait for feedmail to do it for you.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (defvar feedmail-sender-line nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 "*If nil, no SENDER: header is forced. If non-nil and the email
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 already has a FROM: header, a SENDER: header is forced with this as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 its contents. You can probably leave this nil, but if you feel like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 using it, a good value would be a fully-qualified domain name form of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 your address. For example, william.j.carpenter@att.com. Don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 include a trailing newline or the keyword SENDER:. They're
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 automatically provided.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; user-full-name suggested by kpc@ptolemy.arc.nasa.gov (=Kimball Collins)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (defvar feedmail-from-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (concat (user-login-name) "@" (system-name) " (" (user-full-name) ")")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 "*If non-nil and the email has no FROM: header, one will be forced
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 with this as its contents. A good value would be a fully-qualified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 domain name form of your address. For example, william.j.carpenter@att.com.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (The default value of this variable is probably not very good, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 it doesn't have a domain part.) Don't include a trailing newline or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 the keyword FROM:. They're automatically provided.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;; Here's how I use the GNUS Message-ID generator for mail but not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;;; for news postings:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;;; (setq feedmail-message-id-generator 'wjc:gnusish-message-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;;; (setq gnus-your-domain "hos1cad.ATT.COM")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;;; (defun wjc:gnusish-message-id ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;;; (require 'gnuspost)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;;; (if (fboundp 'wjc:gnus-inews-message-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;; (wjc:gnus-inews-message-id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;;; (gnus-inews-message-id)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;; (setq news-inews-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;; '(lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;; (defun gnus-inews-date () nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;; (fset 'wjc:gnus-inews-message-id (symbol-function 'gnus-inews-message-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;;; (defun gnus-inews-message-id () nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;; ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (defvar feedmail-message-id-generator nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 "*If non-nil, should be a function (called with no arguments) which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 will generate a unique message ID which will be inserted on a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 Message-ID: header. The message ID should be the return value of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 function. Don't include trailing newline, leading space, or the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 keyword MESSAGE-ID. They're automatically provided. Do include
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 surrounding <> brackets. For an example of a message ID generating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 function, you could look at the GNUS function gnus-inews-message-id.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 When called, the current buffer is the prepped outgoing mail buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (the function may inspect it, but shouldn't modify it). If the returned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 value doesn't contain any non-whitespace characters, no message ID
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 header is generated, so you could generate them conditionally,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 based on the contents of the mail.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (defun feedmail-confirm-addresses-hook-example ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 "An example of a last chance hook that shows the simple addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 and gets a confirmation. Use as (setq feedmail-last-chance-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 'feedmail-confirm-addresses-hook-example)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (display-buffer feedmail-address-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (if (not (y-or-n-p "How do you like them apples? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (error "Sending...gave up in last chance hook"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (defvar feedmail-last-chance-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 "*User's last opportunity to modify the message on its way out. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 has already had all the header prepping from the standard package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 The next step after running the hook will be to push the buffer into a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 subprocess that mails the mail. The hook might be interested in these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 buffers: (1) feedmail-prepped-text-buffer contains the header and body
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 of the message, ready to go; (2) feedmail-address-buffer contains the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 space-separated, simplified list of addresses which is to be given to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 the subprocess (the hook may change them). feedmail-error-buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 an empty buffer intended to soak up errors for display to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 If the hook allows interactive activity, the user should not send more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 mail while in the hook since some of the internal buffers will be reused.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;; XEmacs change: make the default more sensible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (defvar feedmail-buffer-eating-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (if (and (boundp 'sendmail-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (string-match "sendmail" sendmail-program))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 'feedmail-buffer-to-sendmail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 'feedmail-buffer-to-binmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 "*Function used to send the prepped buffer to a subprocess. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 function's three (mandatory) arguments are: (1) the buffer containing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 the prepped message; (2) a buffer where errors should be directed; and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (3) a string containing the space-separated list of simplified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 addresses. Two popular choices for this are 'feedmail-buffer-to-binmail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 and 'feedmail-buffer-to-sendmail. If you use the sendmail form, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 probably want to set feedmail-nuke-bcc to nil. If you use the binmail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 form, check the value of feedmail-binmail-template.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (defvar feedmail-binmail-template (if mail-interactive "/bin/mail %s" "/bin/rmail %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 "*Command template for the subprocess which will get rid of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 mail. It can result in any command understandable by /bin/sh. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 single '%s', if present, gets replaced by the space-separated,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 simplified list of addressees. Used in feedmail-buffer-to-binmail to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 form the shell command which will receive the contents of the prepped
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 buffer as stdin. If you'd like your errors to come back as mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 instead of immediately in a buffer, try /bin/rmail instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 /bin/mail (this can be accomplished by keeping the default nil setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 of mail-interactive). You might also like to consult local mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 experts for any other interesting command line possibilities.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; feedmail-buffer-to-binmail and feedmail-buffer-to-sendmail are the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;; only things provided for values for the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;; feedmail-buffer-eating-function. It's pretty easy to write your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;; own, though.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (defun feedmail-buffer-to-binmail (prepped-mail-buffer mail-error-buffer simple-address-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 "Function which actually calls /bin/mail as a subprocess and feeds the buffer to it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (set-buffer prepped-mail-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (apply 'call-process-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (append (list (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 "/bin/sh" nil mail-error-buffer nil "-c"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (format feedmail-binmail-template simple-address-list ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ) ;; save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (defun feedmail-buffer-to-sendmail (prepped-mail-buffer feedmail-error-buffer simple-address-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 "Function which actually calls sendmail as a subprocess and feeds the buffer to it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (set-buffer prepped-mail-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (apply 'call-process-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (append (list (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (if (boundp 'sendmail-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 sendmail-program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 "/usr/lib/sendmail")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 nil feedmail-error-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 "-oi" "-t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; Don't say "from root" if running under su.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (and (equal (user-real-login-name) "root")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (list "-f" (user-login-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;; These mean "report errors by mail"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; and "deliver in background".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (if (null mail-interactive) '("-oem" "-odb"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;; feedmail-send-it is the only "public" function is this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;; All of the others are just little helpers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (defun feedmail-send-it ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (let* ((default-case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (feedmail-error-buffer (get-buffer-create " *Outgoing Email Errors*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (feedmail-prepped-text-buffer (get-buffer-create " *Outgoing Email Text*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (feedmail-address-buffer (get-buffer-create " *Outgoing Email Address List*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (feedmail-raw-text-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 end-of-headers-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (unwind-protect (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (set-buffer feedmail-prepped-text-buffer) (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ;; jam contents of user-supplied mail buffer into our scratch buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (insert-buffer-substring feedmail-raw-text-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;; require one newline at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (or (= (preceding-char) ?\n) (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;; Change header-delimiter to be what mailers expect (empty line).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (replace-match "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;; why was this backward-char here?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;;(backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (setq end-of-headers-marker (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (if (and (fboundp 'expand-mail-aliases) ; nil = mail-abbrevs.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 mail-aliases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (expand-mail-aliases (point-min) end-of-headers-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;; make it pretty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (if feedmail-fill-to-cc (feedmail-fill-to-cc-function end-of-headers-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ;; ignore any blank lines in the header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (while (and (re-search-forward "\n\n\n*" end-of-headers-marker t) (< (point) end-of-headers-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (replace-match "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (feedmail-deduce-address-list feedmail-prepped-text-buffer (point-min) end-of-headers-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (save-excursion (set-buffer feedmail-address-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (if (not (re-search-forward "\\S-" (point-max) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (error "Sending...abandoned, no addressees!")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;; Find and handle any BCC fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (if feedmail-nuke-bcc (feedmail-do-bcc end-of-headers-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; Find and handle any FCC fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (if (re-search-forward "^FCC:" end-of-headers-marker t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (mail-do-fcc end-of-headers-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (if (re-search-forward "^FROM:" end-of-headers-marker t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;; If there is a FROM: and no SENDER:, put in a SENDER:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ;; if requested by user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (if (and feedmail-sender-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (not (save-excursion (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (re-search-forward "^SENDER:" end-of-headers-marker t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (progn (forward-line 1) (insert "Sender: " feedmail-sender-line "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;; no FROM: ... force one?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (if feedmail-from-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (progn (goto-char (point-min)) (insert "From: " feedmail-from-line "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ;; don't send out a blank subject line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (if (re-search-forward "^Subject:[ \t]*\n" end-of-headers-marker t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (replace-match ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;; don't send out a blank headers of various sorts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (and feedmail-nuke-empty-headers ;; hey, who's an empty-header?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (while (re-search-forward "^[A-Za-z0-9-]+:[ \t]*\n" end-of-headers-marker t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (replace-match ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ;; message ID generation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (if feedmail-message-id-generator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (if (re-search-forward "^MESSAGE-ID:[ \t]*\n" end-of-headers-marker t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (replace-match ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (setq feedmail-msgid-part (funcall feedmail-message-id-generator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (and feedmail-msgid-part (string-match "[^ \t]" feedmail-msgid-part)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (insert "Message-ID: " feedmail-msgid-part "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (save-excursion (set-buffer feedmail-error-buffer) (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (run-hooks 'feedmail-last-chance-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (if (or (not feedmail-confirm-outgoing) (feedmail-one-last-look feedmail-prepped-text-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (funcall feedmail-buffer-eating-function feedmail-prepped-text-buffer feedmail-error-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (save-excursion (set-buffer feedmail-address-buffer) (buffer-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (error "Sending...abandoned")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ) ;; unwind-protect body (save-excursion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ;; unwind-protect cleanup forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (kill-buffer feedmail-prepped-text-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (kill-buffer feedmail-address-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (set-buffer feedmail-error-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (if (zerop (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (kill-buffer feedmail-error-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (progn (display-buffer feedmail-error-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (error "Sending...failed")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (set-buffer feedmail-raw-text-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ) ;; let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (defun feedmail-do-bcc (header-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 "Delete BCC: and their continuation lines from the header area.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 There may be multiple BCC: lines, and each may have arbitrarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 many continuation lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (save-excursion (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;; iterate over all BCC: lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (while (re-search-forward "^BCC:" header-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (delete-region (match-beginning 0) (progn (forward-line 1) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;; get rid of any continuation lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (while (and (looking-at "^[ \t].*\n") (< (point) header-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (replace-match ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ) ;; save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ) ;; let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (defun feedmail-fill-to-cc-function (header-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 "Smart filling of TO: and CC: headers. The filling tries to avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 splitting lines except at commas. This avoids, in particular,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 splitting within parenthesized comments in addresses."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (fill-prefix "\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (fill-column feedmail-fill-to-cc-fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 this-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 this-line-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (save-excursion (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;; iterate over all TO:/CC: lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (while (re-search-forward "^\\(TO:\\|CC:\\)" header-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (setq this-line (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;; get any continuation lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (while (and (looking-at "^[ \t]+") (< (point) header-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (replace-match " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (setq this-line-end (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ;; The general idea is to break only on commas. Change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 ;; all the blanks to something unprintable; change the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ;; commas to blanks; fill the region; change it back.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (subst-char-in-region this-line this-line-end ? 2 t) ;; blank --> C-b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (subst-char-in-region this-line this-line-end ?, ? t) ;; comma --> blank
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (fill-region-as-paragraph this-line this-line-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (subst-char-in-region this-line this-line-end ? ?, t) ;; comma <-- blank
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (subst-char-in-region this-line this-line-end 2 ? t) ;; blank <-- C-b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;; look out for missing commas before continuation lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (goto-char this-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (while (re-search-forward "\\([^,]\\)\n\t[ ]*" this-line-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (replace-match "\\1,\n\t")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ) ;; while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ) ;; save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (defun feedmail-deduce-address-list (feedmail-text-buffer header-start header-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 "Get address list suitable for command line use on simple /bin/mail."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (require 'mail-utils) ;; pick up mail-strip-quoted-names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (simple-address-list "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 this-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 this-line-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (set-buffer feedmail-address-buffer) (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (insert-buffer-substring feedmail-text-buffer header-start header-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (while (re-search-forward "^\\(TO:\\|CC:\\|BCC:\\)" header-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (replace-match "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (setq this-line (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ;; get any continuation lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (while (and (looking-at "^[ \t]+") (< (point) header-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (setq this-line-end (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (setq simple-address-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (concat simple-address-list " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (mail-strip-quoted-names (buffer-substring this-line this-line-end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (insert-string simple-address-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (subst-char-in-region (point-min) (point-max) 10 ? t) ;; newline --> blank
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (subst-char-in-region (point-min) (point-max) ?, ? t) ;; comma --> blank
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (subst-char-in-region (point-min) (point-max) 9 ? t) ;; tab --> blank
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;; tidyness in case hook is not robust when it looks at this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (while (re-search-forward "[ \t]+" header-end t) (replace-match " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (defun feedmail-one-last-look (feedmail-prepped-text-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 "Offer the user one last chance to give it up."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (save-excursion (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (switch-to-buffer feedmail-prepped-text-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (y-or-n-p "Send this email? "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (provide 'feedmail)