Backport the :end-of-capability fix
[emacs.git] / lisp / mail / feedmail.el
blob7f27599edf2242e91286e2b942a94ca550cf0dd8
1 ;;; feedmail.el --- assist other email packages to massage outgoing messages
2 ;;; This file is in the public domain.
4 ;; This file is part of GNU Emacs.
6 ;; Author: Bill Carpenter <bill@carpenter.ORG>
7 ;; Version: 11
8 ;; Keywords: email, queue, mail, sendmail, message, spray, smtp, draft
9 ;; X-URL: <URL:http://www.carpenter.org/feedmail/feedmail.html>
11 ;;; Commentary:
13 ;; A replacement for parts of sendmail.el (specifically,
14 ;; it's what handles your outgoing mail after you hit C-c C-c in mail
15 ;; mode). See below for a list of additional features, including the
16 ;; ability to queue messages for later sending. This replaces
17 ;; the standalone fakemail program that used to be distributed with Emacs.
19 ;; feedmail works with recent versions of Emacs (20.x series) and
20 ;; XEmacs (tested with 20.4 and later betas). It probably no longer
21 ;; works with Emacs v18, though I haven't tried that in a long
22 ;; time. Makoto.Nakagawa@jp.compaq.com reports: "I have a report
23 ;; that with a help of APEL library, feedmail works fine under emacs
24 ;; 19.28. You can get APEL from ftp://ftp.m17n.org/pub/mule/apel/.
25 ;; you need apel-10.2 or later to make feedmail work under emacs
26 ;; 19.28."
28 ;; Sorry, no manual yet in this release. Look for one with the next
29 ;; release. Or the one after that. Or maybe later.
31 ;; As far as I'm concerned, anyone can do anything they want with
32 ;; this specific piece of code. No warranty or promise of support is
33 ;; offered. This code is hereby released into the public domain.
35 ;; Thanks: My thanks to the many people who have sent me suggestions
36 ;; and fixes over time, as well as those who have tested many beta
37 ;; iterations. Some are cited in comments in code fragments below,
38 ;; but that doesn't correlate well with the list of folks who have
39 ;; actually helped me along the way.
41 ;; If you use feedmail, I invite you to send me some email about it.
42 ;; I appreciate feedback about problems you find or suggestions for
43 ;; improvements or added features (even though I can't predict when
44 ;; I'll incorporate changes). It's also OK with me if you send me a
45 ;; note along the lines of "I use feedmail and find it useful" or "I
46 ;; tried feedmail and didn't find it useful, so I stopped using it".
48 ;; It is most useful, when sending a bug report, if you tell me what
49 ;; version of Emacs you are using, what version of feedmail you are
50 ;; using, and what versions of other email-related elisp packages you
51 ;; are using. If in doubt about any of that, send the bug report
52 ;; anyhow.
54 ;; =====
55 ;; A NOTE TO THOSE WHO WOULD CHANGE THIS CODE... Since it is PD,
56 ;; you're within your rights to do whatever you want. If you do
57 ;; publish a new version with your changes in it, please (1) insert
58 ;; lisp comments describing the changes, (2) insert lisp comments
59 ;; that clearly delimit where your changes are, (3) email me a copy
60 ;; (I can't always consistently follow the relevant usenet groups),
61 ;; and (4) use a version number that is based on the version you're
62 ;; changing along with something that indicates you changed it. For
63 ;; example,
65 ;; (defconst feedmail-patch-level "123")
66 ;; (defconst feedmail-patch-level "123-XYZ-mods")
68 ;; The point of the last item, of course, is to try to minimize
69 ;; confusion. Odds are good that if your idea makes sense to me that
70 ;; it will show up in some future version of feedmail, though it's
71 ;; hard to say when releases will tumble out.
72 ;; =====
74 ;; This file requires the mail-utils library.
76 ;; This file requires the smtpmail library if you use
77 ;; feedmail-buffer-to-smtpmail. It requires the smtp library if
78 ;; you use feedmail-buffer-smtp.
80 ;; This file requires the custom library. Unfortunately, there are
81 ;; two incompatible versions of the custom library. If you don't have
82 ;; custom or you have the old version, this file will still load and
83 ;; work properly. If you don't know what custom is all about and want
84 ;; to edit your user option elisp variables the old fashioned way,
85 ;; just imagine that all the "defcustom" stuff you see below is really
86 ;; "defvar", and ignore everything else. For info about custom, see
87 ;; <URL:http://www.dina.kvl.dk/~abraham/custom/>.
89 ;; This code does in elisp a superset of the stuff that used to be done
90 ;; by the separate program "fakemail" for processing outbound email.
91 ;; In other words, it takes over after you hit "C-c C-c" in mail mode.
92 ;; By appropriate setting of options, you can even revert to sendmail
93 ;; (which is not too popular locally). See the variables at the top
94 ;; of the elisp for how to achieve these effects (there are more
95 ;; features than in this bullet list, so trolling through the variable
96 ;; and function doc strings may be worth your while):
98 ;; --- you can park outgoing messages into a disk-based queue and
99 ;; stimulate sending them all later (handy for laptop users);
100 ;; there is also a queue for draft messages
102 ;; --- you can get one last look at the prepped outbound message and
103 ;; be prompted for confirmation
105 ;; --- removes Bcc:/Resent-Bcc: headers after getting address info
107 ;; --- does smart filling of address headers
109 ;; --- calls a routine to process Fcc: lines and removes them
111 ;; --- empty headers are removed
113 ;; --- can force From: or Sender: line
115 ;; --- can generate a Message-Id: line
117 ;; --- can generate a Date: line; the date can be the time the
118 ;; message was written or the time it is being sent
120 ;; --- strips comments from address info (both "()" and "<>" are
121 ;; handled via a call to mail-strip-quoted-names); the
122 ;; comments are stripped in the simplified address list given
123 ;; to a subprocess, not in the headers in the mail itself
124 ;; (they are left unchanged, modulo smart filling)
126 ;; --- error info is pumped into a normal buffer instead of the
127 ;; minibuffer
129 ;; --- just before the optional prompt for confirmation, lets you
130 ;; run a hook on the prepped message and simplified address
131 ;; list
133 ;; --- you can specify something other than /bin/mail for the
134 ;; subprocess
136 ;; --- you can generate/modify an X-Mailer: message header
138 ;; After a long list of options below, you will find the function
139 ;; feedmail-send-it. Hers's the best way to use the stuff in this
140 ;; file:
142 ;; Save this file as feedmail.el somewhere on your elisp loadpath;
143 ;; byte-compile it. Put the following lines in your init file:
145 ;; (setq send-mail-function 'feedmail-send-it)
146 ;; (autoload 'feedmail-send-it "feedmail")
148 ;; If you plan to use the queue stuff, also use this:
150 ;; (setq feedmail-enable-queue t)
151 ;; (autoload 'feedmail-run-the-queue "feedmail")
152 ;; (autoload 'feedmail-run-the-queue-no-prompts "feedmail")
153 ;; (setq auto-mode-alist (cons '("\\.fqm$" . mail-mode) auto-mode-alist))
155 ;; though VM users might find it more comfortable to use this instead of
156 ;; the above example's last line:
158 ;; (setq auto-mode-alist (cons '("\\.fqm$" . feedmail-vm-mail-mode) auto-mode-alist))
160 ;; If you end up getting asked about killing modified buffers all the time
161 ;; you are probably being prompted from outside feedmail. You can probably
162 ;; get cured by doing the defadvice stuff described in the documentation
163 ;; for the variable feedmail-queue-buffer-file-name below.
165 ;; If you are wondering how to send your messages to some SMTP server
166 ;; (which is not really a feedmail-specific issue), you are probably
167 ;; looking for smtpmail.el, and it is probably already present in your
168 ;; emacs installation. Look at smtpmail.el for how to set that up, and
169 ;; then do this to hook it into feedmail:
171 ;; (autoload 'feedmail-buffer-to-smtpmail "feedmail" nil t)
172 ;; (setq feedmail-buffer-eating-function 'feedmail-buffer-to-smtpmail)
174 ;; Alternatively, the FLIM <http://www.m17n.org/FLIM/> project
175 ;; provides a library called smtp.el. If you want to use that, the above lines
176 ;; would be:
178 ;; (autoload 'feedmail-buffer-to-smtp "feedmail" nil t)
179 ;; (setq feedmail-buffer-eating-function 'feedmail-buffer-to-smtp)
181 ;; If you are using the desktop.el library to restore your sessions, you might
182 ;; like to add the suffix ".fqm" to the list of non-saved things via the variable
183 ;; desktop-files-not-to-save.
185 ;; If you are planning to call feedmail-queue-reminder from your .emacs or
186 ;; something similar, you might need this:
188 ;; (autoload 'feedmail-queue-reminder "feedmail")
190 ;; If you ever use rmail-resend and queue messages, you should do this:
192 ;; (setq feedmail-queue-alternative-mail-header-separator "")
194 ;; If you want to automatically spell-check messages, but not when sending
195 ;; them from the queue, you could do something like this:
197 ;; (autoload 'feedmail-mail-send-hook-splitter "feedmail")
198 ;; (add-hook 'mail-send-hook 'feedmail-mail-send-hook-splitter)
199 ;; (add-hook 'feedmail-mail-send-hook 'ispell-message)
201 ;; If you are using message-mode to compose and send mail, feedmail will
202 ;; probably work fine with that (someone else tested it and told me it worked).
203 ;; Follow the directions above, but make these adjustments instead:
205 ;; (setq message-send-mail-function 'feedmail-send-it)
206 ;; (add-hook 'message-mail-send-hook 'feedmail-mail-send-hook-splitter)
208 ;; If you use message-mode and you make use of feedmail's queueing
209 ;; stuff, you might also like to adjust these variables to appropriate
210 ;; values for message-mode:
212 ;; feedmail-queue-runner-mode-setter
213 ;; feedmail-queue-runner-message-sender
215 ;; If you are using the "cmail" email package, there is some built-in
216 ;; support for feedmail in recent versions. To enable it, you should:
218 ;; (setq cmail-use-feedmail t)
220 ;;;;;;;;
222 ;; I think the LCD is no longer being updated, but if it were, this
223 ;; would be a proper LCD record. There is an old version of
224 ;; feedmail.el in the LCD archive. It works but is missing a lot of
225 ;; features.
227 ;; LCD record:
228 ;; feedmail|WJCarpenter|bill-feedmail@carpenter.ORG|Outbound mail queue handling|01-??-??|11-beta-??|feedmail.el
230 ;; Change log:
231 ;; original, 31 March 1991
232 ;; patchlevel 1, 5 April 1991
233 ;; patchlevel 2, 24 May 1991
234 ;; 5-may-92 jwz Conditionalized calling expand-mail-aliases, since that
235 ;; function doesn't exist in Lucid Emacs or when using
236 ;; mail-abbrevs.el.
237 ;; patchlevel 3, 3 October 1996
238 ;; added queue stuff; still works in v18
239 ;; patchlevel 4, issued by someone else
240 ;; patchlevel 5, issued by someone else
241 ;; patchlevel 6, not issued as far as I know
242 ;; patchlevel 7, 20 May 1997
243 ;; abandon futile support of Emacs 18 (sorry if that hurts you)
244 ;; provide a Date: header by default
245 ;; provide a default for generating Message-Id: header contents
246 ;; and use it by default (slightly changed API)
247 ;; return value from feedmail-run-the-queue
248 ;; new wrapper function feedmail-run-the-queue-no-prompts
249 ;; user-mail-address as default for From:
250 ;; properly deal with Resent-{To,Cc,Bcc}
251 ;; Bcc and Resent-* now included in smart filling
252 ;; limited support for a "drafts" directory
253 ;; user-configurable default message action
254 ;; allow timeout for confirmation prompt (where available)
255 ;; move Fcc handling to as late as possible to get max
256 ;; header munging in the saved file
257 ;; work around sendmail.el's prompts when working from queue
258 ;; more reliably detect voluntary user bailouts
259 ;; offer to save modified buffers visiting queue files
260 ;; offer to delete old file copies of messages being queued
261 ;; offer to delete queue files when sending immediately
262 ;; queue filename convention preserves queue order
263 ;; default queue and draft directory names that work on VMS
264 ;; deduced address list now really a list, not a string (API change)
265 ;; no more address buffer
266 ;; when sending immediately, brief reminder of queue/draft counts
267 ;; copy trace of smtpmail stuff to feedmail error buffer on no-go
268 ;; more granularity on when to confirm sending
269 ;; pause a bit for errors while running queue
270 ;; try to clean up some pesky auto-save files from the
271 ;; queue/draft directories
272 ;; feedmail-force-expand-mail-aliases in case you can't figure
273 ;; any other way
274 ;; cleanup some of my sloppiness about case-fold-search (a strange
275 ;; variable)
276 ;; best effort following coding conventions from Emacs
277 ;; elisp manual appendix
278 ;; "customize" (see custom.el)
279 ;; when user selects "immediate send", clear action prompt since
280 ;; hooks may take a while to operate, and user may think the
281 ;; response didn't take
282 ;; fixes to the argument conventions for the
283 ;; feedmail-queue-runner-* functions; allows
284 ;; feedmail-run-the-queue[-no-prompts] to properly be called
285 ;; non-interactively
286 ;; eliminate reliance on directory-sep-char and feedmail-sep-thing
287 ;; tweak smart filling (reminded of comma problem by levitte@lp.se)
288 ;; option to control writing in text vs binary mode
289 ;; patchlevel 8, 15 June 1998
290 ;; reliable re-editing of text-mode (vs binary) queued messages
291 ;; user option to keep Bcc: in Fcc: copy (keep by default)
292 ;; user option to delete body from Fcc: copy (keep by default)
293 ;; feedmail-deduce-bcc-where for envelope (API change for
294 ;; feedmail-deduce-address list)
295 ;; feedmail-queue-alternative-mail-header-separator
296 ;; at message action prompt, "I"/"S" bypass message confirmation prompt
297 ;; feedmail-mail-send-hook-splitter, feedmail-mail-send-hook,
298 ;; feedmail-mail-send-hook-queued
299 ;; user can supply stuff for message action prompt
300 ;; variable feedmail-queue-runner-confirm-global, function feedmail-run-the-queue-global-prompt
301 ;; bugfix: absolute argument to directory-files (tracked down for me
302 ;; by gray@austin.apc.slb.com (Douglas Gray Stephens)); relative
303 ;; pathnames can tickle stuff in ange-ftp remote directories
304 ;; (perhaps because feedmail is careless about its working
305 ;; directory)
306 ;; feedmail-deduce-envelope-from
307 ;; always supply envelope "from" (user-mail-address) to sendmail
308 ;; feedmail-message-id-suffix
309 ;; feedmail-queue-reminder, feedmail-queue-reminder-alist (after suggestions
310 ;; and/or code fragments from tonyl@Eng.Sun.COM (Tony Lam) and
311 ;; burge@newvision.com (Shane Burgess); bumped up the default value of
312 ;; feedmail-queue-chatty-sit-for since info is more complex sometimes
313 ;; feedmail-enable-spray (individual transmissions, crude mailmerge)
314 ;; blank Subject: no longer a special case; see feedmail-nuke-empty-headers
315 ;; fiddle-plexes data structure used lots of places; see feedmail-fiddle-plex-blurb
316 ;; feedmail-fiddle-plex-user-list
317 ;; feedmail-is-a-resend
318 ;; honor mail-from-style in constructing default for feedmail-from-line
319 ;; re-implement feedmail-from-line and feedmail-sender-line with
320 ;; fiddle-plexes; slightly modified semantics for feedmail-sender-line
321 ;; feedmail-queue-default-file-slug; tidy up some other slug details
322 ;; feedmail-queue-auto-file-nuke
323 ;; feedmail-queue-express-to-queue and feedmail-queue-express-to-draft
324 ;; strong versions of "q"ueue and "d"raft answers (always make a new file)
325 ;; patchlevel 9, 23 March 2001
326 ;; feedmail-queue-buffer-file-name to work around undesirable mail-send prompt
327 ;; at message action prompt, can scroll message buffer with "<" and ">";
328 ;; C-v no longer scrolls help buffer
329 ;; conditionalize (discard-input) in message action prompt to avoid killing
330 ;; define-kbd-macro
331 ;; fixed error if feedmail-x-mailer-line was nil
332 ;; feedmail-binmail-template only uses /bin/rmail if it exists
333 ;; relocate feedmail-queue-alternative-mail-header-separator stuff
334 ;; added feedmail-vm-mail-mode, which make a good auto-mode-alist entry
335 ;; for FQM files if you're a VM user
336 ;; change buffer-substring calls to buffer-substring-no-properties for
337 ;; speed-up (suggested by Howard Melman <howard@silverstream.com>)
338 ;; feedmail-sendmail-f-doesnt-sell-me-out to control "-f" in call to sendmail
339 ;; in feedmail-buffer-to-sendmail
340 ;; better trapping of odd conditions during the running of the queue;
341 ;; thanks to Yigal Hochberg for helping me test much of this by remote
342 ;; control
343 ;; feedmail-debug and feedmail-debug-sit-for
344 ;; feedmail-display-full-frame
345 ;; feedmail-queue-express-hook
346 ;; added example function feedmail-spray-via-bbdb
347 ;; use expand-file-name for setting default directory names
348 ;; define feedmail-binmail-gnulinuxish-template as a suggestion for
349 ;; the value of feedmail-binmail-template on GNU/Linux and maybe other
350 ;; systems with non-classic /bin/[r]mail behavior
351 ;; guard against nil user-mail-address in generating MESSAGE-ID:
352 ;; feedmail-queue-slug-suspect-regexp is now a variable to
353 ;; accommodate non-ASCII environments (thanks to
354 ;; Makoto.Nakagawa@jp.compaq.com for this suggestion)
355 ;; feedmail-buffer-to-smtp, to parallel feedmail-buffer-to-smtpmail
356 ;; patchlevel 10, 22 April 2001
357 ;; DATE: and MESSAGE-ID stuff now forces system-time-locale to "C"
358 ;; (brought to my attention by Makoto.Nakagawa@jp.compaq.com)
359 ;; patchlevel 11
360 ;; tweak default FROM: calculation to look at mail-host-address
361 ;; (suggested by "Jason Eisner" <jason@cs.jhu.edu>)
363 ;; todo:
364 ;; write texinfo manual
365 ;; maybe partition into multiple files, including files of examples
367 ;;; Code:
369 (defconst feedmail-patch-level "11-beta-1")
371 (require 'mail-utils) ; pick up mail-strip-quoted-names
373 (autoload 'mail-do-fcc "sendmail")
375 (defgroup feedmail nil
376 "Assist other email packages to massage outgoing messages."
377 :link '(url-link "http://www.carpenter.org/feedmail/feedmail.html")
378 :link '(emacs-commentary-link "feedmail")
379 :group 'mail)
381 (defgroup feedmail-misc nil
382 "Miscellaneous feedmail options that don't fit in other groups."
383 :group 'feedmail)
385 (defgroup feedmail-headers nil
386 "Options related to manipulating specific headers or types of headers."
387 :group 'feedmail)
389 (defgroup feedmail-queue nil
390 "Options related to queuing messages for later sending."
391 :group 'feedmail)
393 (defgroup feedmail-debug nil
394 "Options related to debug messages for later sending."
395 :group 'feedmail)
398 (defcustom feedmail-confirm-outgoing nil
399 "If non-nil, give a y-or-n confirmation prompt before sending mail.
400 This is done after the message is completely prepped, and you'll be
401 looking at the top of the message in a buffer when you get the prompt.
402 If set to the symbol 'queued, give the confirmation prompt only while
403 running the queue (however, the prompt is always suppressed if you are
404 processing the queue via `feedmail-run-the-queue-no-prompts'). If set
405 to the symbol 'immediate, give the confirmation prompt only when
406 sending immediately. For any other non-nil value, prompt in both
407 cases. You can give a timeout for the prompt; see variable
408 `feedmail-confirm-outgoing-timeout'."
409 :group 'feedmail-misc
410 :type '(choice (const nil)
411 (const queued)
412 (const immediate)
413 (other t)))
416 (defcustom feedmail-display-full-frame 'queued
417 "If non-nil, show prepped messages in a full frame.
418 If nil, the prepped message will be shown, for confirmation or
419 otherwise, in some window in the current frame without resizing
420 anything. That may or may not display enough of the message to
421 distinguish it from others. If set to the symbol 'queued, take
422 this action only when running the queue. If set to the symbol
423 'immediate, take this action only when sending immediately. For
424 any other non-nil value, take the action in both cases. Even if
425 you're not confirming the sending of immediate or queued messages,
426 it can still be interesting to see a lot about them as they are
427 shuttled robotically onward."
428 :version "24.1"
429 :group 'feedmail-misc
430 :type '(choice (const nil)
431 (const queued)
432 (const immediate)
433 (other t)))
436 (defcustom feedmail-confirm-outgoing-timeout nil
437 "If non-nil, a timeout in seconds at the send confirmation prompt.
438 If a positive number, it's a timeout before sending. If a negative
439 number, it's a timeout before not sending. This will not work if your
440 version of Emacs doesn't include the function `y-or-n-p-with-timeout'
441 \(e.g., some versions of XEmacs\)."
442 :version "24.1"
443 :group 'feedmail-misc
444 :type '(choice (const nil) integer)
448 (defcustom feedmail-nuke-bcc t
449 "If non-nil remove Bcc: lines from the message headers.
450 In any case, the Bcc: lines do participate in the composed address
451 list. You may want to leave them in if you're using sendmail
452 \(see `feedmail-buffer-eating-function'\)."
453 :group 'feedmail-headers
454 :type 'boolean
458 (defcustom feedmail-nuke-resent-bcc t
459 "If non-nil remove Resent-Bcc: lines from the message headers.
460 In any case, the Resent-Bcc: lines do participate in the composed
461 address list. You may want to leave them in if you're using sendmail
462 \(see `feedmail-buffer-eating-function'\)."
463 :group 'feedmail-headers
464 :type 'boolean
468 (defcustom feedmail-deduce-bcc-where nil
469 "Where Bcc:/Resent-Bcc: addresses should appear in the envelope list.
470 Addresses for the message envelope are deduced by examining
471 appropriate address headers in the message. Generally, they will show
472 up in the list of deduced addresses in the order that the headers
473 happen to appear (duplicate addresses are eliminated in any case).
474 This variable can be set to the symbol 'first, in which case the
475 Bcc:/Resent-Bcc: addresses will appear at the beginning in the list;
476 or, it can be set to the symbol 'last, in which case they will appear
477 at the end of the list.
479 Why should you care? Well, maybe you don't, and certainly the same
480 things could be accomplished by affecting the order of message headers
481 in the outgoing message. Some people use Bcc: as a way of getting
482 their own \"come back\" copy of each message they send. If Bcc:
483 addresses are not handled first, there can be substantial delays in
484 seeing the message again. Some configurations of sendmail, for example,
485 seem to try to deliver to each addressee at least once, immediately
486 and serially, so slow SMTP conversations can add up to a delay. There
487 is an option for either 'first or 'last because you might have a
488 delivery agent that processes the addresses backwards."
489 :group 'feedmail-headers
490 :type '(choice (const nil)
491 (const first)
492 (const last)))
495 (defcustom feedmail-fill-to-cc t
496 "If non-nil do smart filling of addressee header lines.
497 Smart filling means breaking long lines at appropriate points and
498 making continuation lines. Despite the function name, it includes
499 To:, Cc:, Bcc: (and their Resent-* forms), as well as From: and
500 Reply-To: (though they seldom need it). If nil, the lines are left
501 as-is. The filling is done after mail address alias expansion."
502 :group 'feedmail-headers
503 :type 'boolean
507 (defcustom feedmail-fill-to-cc-fill-column default-fill-column
508 "Fill column used by `feedmail-fill-to-cc'."
509 :group 'feedmail-headers
510 :type 'integer
514 (defcustom feedmail-nuke-bcc-in-fcc nil
515 "If non-nil remove [Resent-]Bcc: lines in message copies saved via Fcc:.
516 This is independent of whether the Bcc: header lines are actually sent
517 with the message (see feedmail-nuke-bcc). Though not implied in the name,
518 the same Fcc: treatment applies to both Bcc: and Resent-Bcc: lines."
519 :group 'feedmail-headers
520 :type 'boolean
524 (defcustom feedmail-nuke-body-in-fcc nil
525 "If non-nil remove body of message in copies saved via Fcc:.
526 If a positive integer value, leave (up to) that many lines of the
527 beginning of the body intact. The result is that the Fcc: copy will
528 consist only of the message headers, serving as a sort of an outgoing
529 message log."
530 :group 'feedmail-headers
531 :type '(choice (const nil) (const t) integer)
535 (defcustom feedmail-force-expand-mail-aliases nil
536 "If non-nil, force the calling of `expand-mail-aliases'.
537 Normally, feedmail tries to figure out if you're using mailalias or
538 mailabbrevs and only calls `expand-mail-aliases' if it thinks you're
539 using the mailalias package. This user option can be used to force
540 the issue since there are configurations which fool the figuring
541 out."
542 :group 'feedmail-headers
543 :type 'boolean
547 (defcustom feedmail-nuke-empty-headers t
548 "If non-nil, remove header lines which have no contents.
549 A completely empty Subject: header is always removed, regardless of
550 the setting of this variable. The only time you would want them left
551 in would be if you used some headers whose presence indicated
552 something rather than their contents. This is rare in Internet email
553 but common in some proprietary systems."
554 :group 'feedmail-headers
555 :type 'boolean
558 ;; wjc sez: I think the use of the Sender: line is pretty pointless,
559 ;; but I left it in to be compatible with sendmail.el and because
560 ;; maybe some distant mail system needs it. Really, though, if you
561 ;; want a sender line in your mail, just put one in there and don't
562 ;; wait for feedmail to do it for you. (Yes, I know all about
563 ;; RFC-822 and RFC-1123, but are you *really* one of those cases
564 ;; they're talking about? I doubt it.)
565 (defcustom feedmail-sender-line nil
566 "If non-nil and the email has no Sender: header, use this value.
567 May be nil, in which case nothing in particular is done with respect
568 to Sender: lines. By design, will not replace an existing Sender:
569 line, but you can achieve that with a fiddle-plex 'replace action.
570 NB: it makes no sense to use the value t since there is no sensible
571 default for Sender:.
573 If not nil, it may be a string, a fiddle-plex, or a function which
574 returns either nil, t, a string, or a fiddle-plex (or, in fact,
575 another function, but let's not be ridiculous). If a string, it
576 should be just the contents of the header, not the name of the header
577 itself nor the trailing newline. If a function, it will be called
578 with no arguments. For an explanation of fiddle-plexes, see the
579 documentation for the variable `feedmail-fiddle-plex-blurb'. In all
580 cases the name element of the fiddle-plex is ignored and is hardwired
581 by feedmail to either \"Sender\" or \"Resent-Sender\".
583 You can probably leave this nil, but if you feel like using it, a good
584 value would be a string of a fully-qualified domain name form of your
585 address. For example, \"bill@example.net (WJCarpenter)\". The Sender:
586 header is fiddled after the From: header is fiddled."
587 :group 'feedmail-headers
588 :type '(choice (const nil) string)
592 (defcustom feedmail-force-binary-write t
593 "If non-nil, force writing file as binary (this applies to queues and Fcc:).
594 On systems where there is a difference between binary and text files,
595 feedmail will temporarily manipulate the value of `coding-system-for-write'
596 to make the writing as binary. If nil, writing will be in text mode.
597 On systems where there is no distinction or where it is controlled by other
598 variables or other means, this option has no effect."
599 :group 'feedmail-misc
600 :type 'boolean
604 (defcustom feedmail-from-line t
605 "If non-nil and the email has no From: header, use this value.
606 May be t, in which case a default is computed (and you probably won't
607 be happy with it). May be nil, in which case nothing in particular is
608 done with respect to From: lines. By design, will not replace an
609 existing From: line, but you can achieve that with a fiddle-plex 'replace
610 action.
612 If neither nil nor t, it may be a string, a fiddle-plex, or a function
613 which returns either nil, t, a string, or a fiddle-plex (or, in fact,
614 another function, but let's not be ridiculous). If a string, it
615 should be just the contents of the header, not the name of the header
616 itself nor the trailing newline. If a function, it will be called
617 with no arguments. For an explanation of fiddle-plexes, see the
618 documentation for the variable `feedmail-fiddle-plex-blurb'. In all
619 cases the name element of the fiddle-plex is ignored and is hardwired
620 by feedmail to either \"From\" or \"Resent-From\".
622 A good value would be a string fully-qualified domain name form of
623 your address. For example, \"bill@example.net (WJCarpenter)\". The
624 default value of this variable uses the standard elisp variable
625 `user-mail-address' which should be set on every system but has a decent
626 chance of being wrong. It also honors `mail-from-style'. Better to set
627 this variable explicitly to the string you want or find some other way
628 to arrange for the message to get a From: line."
629 :group 'feedmail-headers
630 :type '(choice (const t) (const nil) string)
634 (defcustom feedmail-sendmail-f-doesnt-sell-me-out nil
635 "Says whether the sendmail program issues a warning header if called with \"-f\".
636 The sendmail program has a useful feature to let you set the envelope FROM
637 address via a command line option, \"-f\". Unfortunately, it also has a widely
638 disliked default behavior of selling you out if you do that by inserting
639 an unattractive warning in the headers. It looks something like this:
641 X-Authentication-Warning: u1.example.com: niceguy set sender to niceguy@example.com using -f
643 It is possible to configure sendmail to not do this, but such a reconfiguration
644 is not an option for many users. As this is the default behavior of most
645 sendmail installations, one can mostly only wish it were otherwise. If feedmail
646 believes the sendmail program will sell you out this way, it won't use the \"-f\"
647 option when calling sendmail. If it doesn't think sendmail will sell you out,
648 it will use the \"-f\" \(since it is a handy feature\). You control what
649 feedmail thinks with this variable. The default is nil, meaning that feedmail
650 will believe that sendmail will sell you out."
651 :version "24.1"
652 :group 'feedmail-headers
653 :type 'boolean
657 (defcustom feedmail-deduce-envelope-from t
658 "If non-nil, deduce message envelope \"from\" from header From: or Sender:.
659 In other words, if there is a Sender: header in the message, temporarily
660 change the value of `user-mail-address' to be the same while the message
661 is being sent. If there is no Sender: header, use the From: header,
662 if any. Address values are taken from the actual message just before
663 it is sent, and the process is independent of the values of
664 `feedmail-from-line' and/or `feedmail-sender-line'.
666 There are many and good reasons for having the message header
667 From:/Sender: be different from the message envelope \"from\"
668 information. However, for most people and for most circumstances, it
669 is usual for them to be the same (this is probably especially true for
670 the case where the user doesn't understand the difference between the
671 two in the first place).
673 The idea behind this feature is that you can have everything set up
674 some normal way for yourself. If for some reason you want to send a
675 message with another From: line, you can just type it at the top of
676 the message, and feedmail will take care of \"fixing up\" the envelope
677 \"from\". This only works for mail senders which make use of
678 `user-mail-address' as the envelope \"from\" value. For some mail
679 senders (e.g., feedmail-buffer-to-bin-mail), there is no simple way to
680 influence what they will use as the envelope."
681 :group 'feedmail-headers
682 :type 'boolean
686 (defcustom feedmail-x-mailer-line-user-appendage nil
687 "See feedmail-x-mailer-line."
688 :group 'feedmail-headers
689 :type '(choice (const nil) (const t) string)
693 (defcustom feedmail-x-mailer-line t
694 "Control the form of an X-Mailer: header in an outgoing message.
695 Moderately useful for debugging, keeping track of your correspondents'
696 mailer preferences, or just wearing your MUA on your sleeve. You
697 should probably know that some people are fairly emotional about the
698 presence of X-Mailer: lines in email.
700 If nil, nothing is done about X-Mailer:.
702 If t, an X-Mailer: header of a predetermined format is produced,
703 combining its efforts with any existing X-Mailer: header. If you want
704 to take the default construct and just add a little blob of your own
705 at the end, define the variable feedmail-x-mailer-line-user-appendage
706 as that blob string. A value of t is equivalent to using the function
707 feedmail-default-x-mailer-generator.
709 If neither nil nor t, it may be a string, a fiddle-plex, or a function
710 which returns either nil, t, a string, or a fiddle-plex (or, in fact,
711 another function, but let's not be ridiculous). If a string, it
712 should be just the contents of the header, not the name of the header
713 itself nor the trailing newline. If a function, it will be called
714 with no arguments. For an explanation of fiddle-plexes, see the
715 documentation for the variable `feedmail-fiddle-plex-blurb'. In all
716 cases the name element of the fiddle-plex is ignored and is hardwired
717 by feedmail to either \"X-Mailer\" or \"X-Resent-Mailer\"."
718 :group 'feedmail-headers
719 :type '(choice (const t) (const nil) string function)
723 (defcustom feedmail-message-id-generator t
724 "Specifies the creation of a Message-Id: header field.
726 If nil, nothing is done about Message-Id:.
728 If t, a Message-Id: header of a predetermined format is produced, but
729 only if there is not already a Message-Id: in the message. A value of
730 t is equivalent to using the function feedmail-default-message-id-generator.
732 If neither nil nor t, it may be a string, a fiddle-plex, or a function
733 which returns either nil, t, a string, or a fiddle-plex (or, in fact,
734 another function, but let's not be ridiculous). If a string, it
735 should be just the contents of the header, not the name of the header
736 itself nor the trailing newline. If a function, it will be called
737 with one argument: the possibly-nil name of the file associated with
738 the message buffer. For an explanation of fiddle-plexes, see the
739 documentation for the variable `feedmail-fiddle-plex-blurb'. In all
740 cases the name element of the fiddle-plex is ignored and is hardwired
741 by feedmail to either \"Message-Id\" or \"Resent-Message-Id\".
743 You should let feedmail generate a Message-Id: for you unless you are sure
744 that whatever you give your messages to will do it for you (e.g., most
745 configurations of sendmail). Even if the latter case is true, it
746 probably won't hurt you to generate your own, and it will then show up
747 in the saved message if you use Fcc:."
748 :group 'feedmail-headers
749 :type '(choice (const t) (const nil) function)
753 (defcustom feedmail-message-id-suffix nil
754 "If non-nil, used as a suffix for generating unique Message-Id: headers.
755 The function `feedmail-default-message-id-generator' creates its work based
756 on a formatted date-time string, a random number, and a domain-looking suffix.
757 You can control the suffix used by assigning a string value to this variable.
758 If you don't supply one, the value of the variable `user-mail-address' will be
759 used. If the value of `feedmail-message-id-suffix' contains an \"@\" character,
760 the string will be used verbatim, else an \"@\" character will be prepended
761 automatically."
762 :group 'feedmail-headers
763 :type '(choice (const nil) string)
766 ;; this was suggested in various forms by several people; first was
767 ;; Tony DeSimone in Oct 1992; sorry to be so tardy
768 (defcustom feedmail-date-generator t
769 "Specifies the creation of a Date: header field.
771 If nil, nothing is done about Date:.
773 If t, a Date: header of a predetermined format is produced, but only
774 if there is not already a Date: in the message. A value of t is
775 equivalent to using the function `feedmail-default-date-generator'.
777 If neither nil nor t, it may be a string, a fiddle-plex, or a function
778 which returns either nil, t, a string, or a fiddle-plex (or, in fact,
779 another function, but let's not be ridiculous). If a string, it
780 should be just the contents of the header, not the name of the header
781 itself nor the trailing newline. If a function, it will be called
782 with one argument: the possibly-nil name of the file associated with
783 the message buffer. For an explanation of fiddle-plexes, see the
784 documentation for the variable `feedmail-fiddle-plex-blurb'. In all
785 cases the name element of the fiddle-plex is ignored and is hardwired
786 by feedmail to either \"Date\" or \"Resent-Date\".
788 If you decide to format your own date field, do us all a favor and know
789 what you're doing. Study the relevant parts of RFC-822 and RFC-1123.
790 Don't make me come up there!
792 You should let feedmail generate a Date: for you unless you are sure
793 that whatever you give your messages to will do it for you (e.g., most
794 configurations of sendmail). Even if the latter case is true, it
795 probably won't hurt you to generate your own, and it will then show up
796 in the saved message if you use Fcc:."
797 :group 'feedmail-headers
798 :type '(choice (const t) (const nil) function)
802 (defcustom feedmail-fiddle-headers-upwardly t
803 "Non-nil means fiddled header fields should go at the top of the header.
804 nil means insert them at the bottom. This is mostly a novelty issue since
805 the standards define the ordering of header fields to be immaterial and it's
806 fairly likely that some MTA/MUA along the way will have its own idea of what the
807 order should be, regardless of what you specify."
808 :group 'feedmail-headers
809 :type 'boolean
813 (defcustom feedmail-fiddle-plex-user-list nil
814 "If non-nil, should be a list of one or more fiddle-plexes.
815 Each element of the list can also be a function which returns a
816 fiddle-plex.
818 feedmail will use this list of fiddle-plexes to manipulate user-specified
819 message header fields. It does this after it has completed all normal
820 message header field manipulation and before calling `feedmail-last-chance-hook'.
822 For an explanation of fiddle-plexes, see the documentation for the
823 variable `feedmail-fiddle-plex-blurb'. In contrast to some other fiddle-plex
824 manipulation functions, in this context, it makes no sense to have an element
825 which is nil, t, or a simple string."
826 :group 'feedmail-headers
827 :type '(repeat (choice function)
828 sexp) ; too complex to be described accurately
832 (defcustom feedmail-enable-spray nil
833 "If non-nil, transmit message separately to each addressee.
834 feedmail normally accumulates a list of addressees and passes the message
835 along with that list to a buffer-eating function which expects any number
836 of addressees. If this variable is non-nil, however, feedmail will
837 repeatedly call the same buffer-eating function. Each time, the list of
838 addressees will be just one item from the original list. This only affects
839 the message envelope addresses and doesn't affect what appears in the
840 message headers except as noted.
842 Spray mode is usually pointless, and if you can't think of a good reason for
843 it, you should avoid it since it is inherently less efficient than normal
844 multiple delivery. One reason to use it is to overcome mis-featured mail
845 transports which betray your trust by revealing Bcc: addressees in the
846 headers of a message. Another use is to do a crude form of mailmerge, for
847 which see `feedmail-spray-address-fiddle-plex-list'.
849 If one of the calls to the buffer-eating function results in an error,
850 what happens next is carelessly defined, so beware. This should get ironed
851 out in some future release, and there could be other API changes for spraying
852 as well."
853 :group 'feedmail-spray
854 :type 'boolean
857 (defvar feedmail-spray-this-address nil
858 "Do not set this variable, except via `feedmail-spray-address-fiddle-plex-list'.")
860 (defcustom feedmail-spray-address-fiddle-plex-list nil
861 "User-supplied specification for a crude form of mailmerge capability.
862 When spraying is enabled, feedmail composes a list of envelope addresses.
863 In turn, `feedmail-spray-this-address' is temporarily set to each address
864 \(stripped of any comments and angle brackets\) and a function is called which
865 fiddles message headers according to this variable. See the documentation for
866 `feedmail-fiddle-plex-blurb', for an overview of fiddle-plex data structures.
868 May be nil, in which case nothing in particular is done about message
869 headers for specific addresses.
871 May be t, in which case a \"To:\" header is added to the message with
872 the stripped address as the header contents. The fiddle-plex operator
873 is 'supplement.
875 May be a string, in which case the string is assumed to be the name of
876 a message header field with the stripped address serving as the value.
877 The fiddle-plex operator is 'supplement.
879 May be a function, in which case it is called with no arguments and is
880 expected to return nil, t, a string, another function, or a fiddle-plex.
881 The result is used recursively. The function may alter the value of the
882 variable feedmail-spray-this-address, perhaps to embellish it with a
883 human name. It would be logical in such a case to return as a value a
884 string naming a message header like \"TO\" or an appropriately constructed
885 fiddle-plex. For an example, see feedmail-spray-via-bbdb.
887 May be a list of any combination of the foregoing and/or
888 fiddle-plexes. (A value for this variable which consists of a single
889 fiddle-plex must be nested inside another list to avoid ambiguity.)
890 If a list, each item is acted on in turn as described above.
892 For example,
894 (setq feedmail-spray-address-fiddle-plex-list 'feedmail-spray-via-bbdb)
896 The idea of the example is that, during spray mode, as each message is
897 about to be transmitted to an individual address, the function will be
898 called and will consult `feedmail-spray-this-address' to find the
899 stripped envelope email address (no comments or angle brackets). The
900 function should return an embellished form of the address.
902 The recipe for sending form letters is: (1) create a message with all
903 addressees on Bcc: headers; (2) tell feedmail to remove Bcc: headers
904 before sending the message; (3) create a function which will embellish
905 stripped addresses, if desired; (4) define `feedmail-spray-address-fiddle-plex-list'
906 appropriately; (5) send the message with `feedmail-enable-spray' set
907 non-nil; (6) stand back and watch co-workers wonder at how efficient
908 you are at accomplishing inherently inefficient things."
909 :group 'feedmail-spray
910 :type 'sexp ; too complex to be described accurately
913 ;; FIXME this is a macro?
914 (declare-function bbdb-search "ext:bbdb-com"
915 (records &optional name company net notes phone))
916 (declare-function bbdb-records "ext:bbdb"
917 (&optional dont-check-disk already-in-db-buffer))
918 (declare-function bbdb-dwim-net-address "ext:bbdb-com" (record &optional net))
920 (defun feedmail-spray-via-bbdb ()
921 "Example function for use with feedmail spray mode.
922 NB: it's up to the user to have the BBDB environment already set up properly
923 before using this."
924 (let (net-rec q-net-addy embellish)
925 (setq q-net-addy (concat "^" (regexp-quote feedmail-spray-this-address) "$"))
926 (setq net-rec (bbdb-search (bbdb-records) nil nil q-net-addy))
927 (if (and (car net-rec) (not (cdr net-rec)))
928 (setq net-rec (car net-rec))
929 (setq net-rec nil))
930 (if net-rec (setq embellish (bbdb-dwim-net-address net-rec)))
931 (if embellish
932 (list "To" embellish 'supplement)
933 (list "To" feedmail-spray-this-address 'supplement))))
936 (defcustom feedmail-enable-queue nil
937 "If non-nil, provide for stashing outgoing messages in a queue.
938 This is the master on/off switch for feedmail message queuing.
939 Queuing is quite handy for laptop-based users. It's also handy if you
940 get a lot of mail and process it more or less sequentially. For
941 example, you might change your mind about contents of a reply based on
942 a message you see a bit later.
944 There is a separate queue for draft messages, intended to prevent
945 you from accidentally sending incomplete messages. The queues are
946 disk-based and intended for later transmission. The messages are
947 queued in their raw state as they appear in the mail-mode buffer and
948 can be arbitrarily edited later, before sending, by visiting the
949 appropriate file in the queue directory (and setting the buffer to
950 mail-mode or whatever). If you visit a file in the queue directory
951 and try to queue it again, it will just get saved in its existing file
952 name. You can move a message from the draft to the main queue or vice
953 versa by pretending to send it and then selecting whichever queue
954 directory you want at the prompt. The right thing will happen.
956 To transmit all the messages in the queue, invoke the command
957 `feedmail-run-the-queue' or `feedmail-run-the-queue-no-prompts'."
958 :group 'feedmail-queue
959 :type 'boolean
963 (defcustom feedmail-queue-runner-confirm-global nil
964 "If non-nil, give a y-or-n confirmation prompt before running the queue.
965 Prompt even if the queue is about to be processed as a result of a call to
966 `feedmail-run-the-queue-no-prompts'. This gives you a way to bail out
967 without having to answer no to the individual message prompts."
968 :group 'feedmail-queue
969 :type 'boolean)
972 (defcustom feedmail-queue-directory
973 (expand-file-name "~/mail/q")
974 "Name of a directory where messages will be queued.
975 Directory will be created if necessary. Should be a string that
976 doesn't end with a slash. Default is \"~/mail/q\"."
977 :group 'feedmail-queue
978 :type 'string
982 (defcustom feedmail-queue-draft-directory
983 (expand-file-name "~/mail/draft")
984 "Name of a directory where draft messages will be queued.
985 Directory will be created if necessary. Should be a string that
986 doesn't end with a slash. Default is \"~/mail/draft\"."
987 :group 'feedmail-queue
988 :type 'string
992 (defcustom feedmail-ask-before-queue t
993 "If non-nil, feedmail will ask what you want to do with the message.
994 Default choices for the message action prompt will include sending it
995 immediately, putting it in the main queue, putting it in the draft
996 queue, or returning to the buffer to continue editing. Only matters if
997 queuing is enabled. If nil, the message is placed in the main queue
998 without a prompt."
999 :group 'feedmail-queue
1000 :type 'boolean
1004 (defcustom feedmail-ask-before-queue-prompt "FQM: Message action (q, i, d, e, ?)? [%s]: "
1005 "A string which will be used for the message action prompt.
1006 If it contains a \"%s\", that will be replaced with the value of
1007 `feedmail-ask-before-queue-default'."
1008 :group 'feedmail-queue
1009 :type 'string
1013 (defcustom feedmail-ask-before-queue-reprompt "FQM: Please type q, i, d, or e; or ? for help [%s]: "
1014 "A string which will be used for reprompting after invalid input.
1015 If it contains a \"%s\", that will be replaced with the value of
1016 `feedmail-ask-before-queue-default'."
1017 :group 'feedmail-queue
1018 :type 'string
1022 (defcustom feedmail-ask-before-queue-default "queue"
1023 "Meaning if user hits return in response to the message action prompt.
1024 Should be a character or a string; if a string, only the first
1025 character is significant. Useful values are those described in
1026 the help for the message action prompt."
1027 :group 'feedmail-queue
1028 :type '(choice string integer) ;use integer to get char
1032 (defvar feedmail-prompt-before-queue-standard-alist
1033 '((?q . feedmail-message-action-queue)
1034 (?Q . feedmail-message-action-queue-strong)
1036 (?d . feedmail-message-action-draft)
1037 (?r . feedmail-message-action-draft)
1038 (?D . feedmail-message-action-draft-strong)
1039 (?R . feedmail-message-action-draft-strong)
1041 (?e . feedmail-message-action-edit)
1042 (?E . feedmail-message-action-edit)
1043 (?\C-g . feedmail-message-action-edit)
1044 (?n . feedmail-message-action-edit)
1045 (?N . feedmail-message-action-edit)
1047 (?i . feedmail-message-action-send)
1048 (?I . feedmail-message-action-send-strong)
1049 (?s . feedmail-message-action-send)
1050 (?S . feedmail-message-action-send-strong)
1052 (?* . feedmail-message-action-toggle-spray)
1054 (?> . feedmail-message-action-scroll-up)
1055 (?< . feedmail-message-action-scroll-down)
1056 (? . feedmail-message-action-scroll-up)
1057 ;; (?\C-v . feedmail-message-action-help)
1058 (?? . feedmail-message-action-help))
1059 "An alist of choices for the message action prompt.
1060 All of the values are function names, except help, which is a special
1061 symbol that calls up help for the prompt (the help describes the
1062 actions from the standard alist). To customize your own choices,
1063 define a similar alist called `feedmail-prompt-before-queue-user-alist'.
1064 The actual alist used for message action will be the standard alist
1065 overlaid with the user-alist. To neutralize an item in the standard
1066 alist without providing a replacement, define an appropriate element
1067 in the user alist with a value of nil." )
1070 (defcustom feedmail-prompt-before-queue-user-alist nil
1071 "See `feedmail-prompt-before-queue-standard-alist'."
1072 :group 'feedmail-queue
1073 :type '(repeat (cons character function))
1077 (defcustom feedmail-prompt-before-queue-help-supplement nil
1078 "User-provided supplementary help string for the message action prompt.
1079 When the message action prompt is shown, the user can as for verbose help,
1080 at which point a buffer pops up describing the meaning of possible
1081 responses to the prompt. Through various customizations (see, for
1082 example, `feedmail-prompt-before-queue-user-alist'), the available responses
1083 and the prompt itself can be changed. If this variable is set to a string
1084 value, that string is written to the help buffer after the standard info.
1085 It may contain embedded line breaks. It will be printed via `princ'."
1086 :group 'feedmail-queue
1087 :type '(choice (const nil) string)
1091 (defcustom feedmail-queue-reminder-alist
1092 '((after-immediate . feedmail-queue-reminder-brief)
1093 (after-queue . feedmail-queue-reminder-medium)
1094 (after-draft . feedmail-queue-reminder-medium)
1095 (after-run . feedmail-queue-reminder-brief)
1096 (on-demand . feedmail-run-the-queue-global-prompt))
1097 "See `feedmail-queue-reminder'."
1098 :group 'feedmail-queue
1099 :type '(repeat (cons (choice :tag "Event"
1100 (const on-demand)
1101 (const after-immediate)
1102 (const after-queue)
1103 (const after-draft)
1104 (const after-run))
1105 function))
1109 (defcustom feedmail-queue-chatty t
1110 "If non-nil, blat a few status messages and such in the mini-buffer.
1111 If nil, just do the work and don't pester people about what's going on.
1112 In some cases, though, specific options inspire mini-buffer prompting.
1113 That's not affected by this variable setting. Also does not control
1114 reporting of error/abnormal conditions."
1115 :group 'feedmail-queue
1116 :type 'boolean
1120 (defcustom feedmail-queue-chatty-sit-for 2
1121 "Duration of pause after most queue-related messages.
1122 After some messages are divulged, it is prudent to pause before
1123 something else obliterates them. This value controls the duration of
1124 the pause."
1125 :group 'feedmail-queue
1126 :type 'integer
1130 (defcustom feedmail-queue-run-orderer nil
1131 "If non-nil, name a function which will sort the queued messages.
1132 The function is called during a running of the queue for sending, and
1133 takes one argument, a list of the files in the queue directory. It
1134 may contain the names of non-message files, and it's okay to leave
1135 them in the list when reordering it; they get skipped over later.
1136 When nil, the default action processes the messages in normal sort
1137 order by queued file name, which will typically result in the order
1138 they were placed in the queue."
1139 :group 'feedmail-queue
1140 :type '(choice (const nil) function)
1144 (defcustom feedmail-queue-use-send-time-for-date nil
1145 "If non-nil, use send time for the Date: header value.
1146 This variable is used by the default date generating function,
1147 feedmail-default-date-generator. If nil, the default, the
1148 last-modified timestamp of the queue file is used to create the
1149 message Date: header; if there is no queue file, the current time is
1150 used. If you are using VM, it might be supplying this header for
1151 you. To suppress VM's version
1153 (setq vm-mail-header-insert-date nil)"
1154 :group 'feedmail-queue
1155 :type 'boolean
1159 (defcustom feedmail-queue-use-send-time-for-message-id nil
1160 "If non-nil, use send time for the Message-Id: header value.
1161 This variable is used by the default Message-Id: generating function,
1162 `feedmail-default-message-id-generator'. If nil, the default, the
1163 last-modified timestamp of the queue file is used to create the
1164 message Message-Id: header; if there is no queue file, the current time is
1165 used. If you are using VM, it might be supplying this header for
1166 you. To suppress VM's version
1168 (setq vm-mail-header-insert-date nil)"
1169 :group 'feedmail-queue
1170 :type 'boolean
1174 (defcustom feedmail-ask-for-queue-slug nil
1175 "If non-nil, prompt user for part of the queue file name.
1176 The file will automatically get the FQM suffix and an embedded
1177 sequence number for uniqueness, so don't specify that. feedmail will
1178 get rid of all characters other than alphanumeric and hyphen in the
1179 results. If this variable is nil or if you just hit return in
1180 response to the prompt, feedmail queuing will take care of things
1181 properly. At the prompt, completion is available if you want to see
1182 what filenames are already in use, though, as noted, you will not be
1183 typing a complete file name. You probably don't want to be bothered
1184 with this prompting since feedmail, by default, uses queue file names
1185 based on the subjects of the messages."
1186 :group 'feedmail-queue
1187 :type 'boolean
1191 (defcustom feedmail-queue-slug-maker 'feedmail-queue-subject-slug-maker
1192 "If non-nil, a function which creates part of the queued file name.
1193 Takes a single argument giving the name of the directory into
1194 which the message will be queued. The returned string should be just
1195 the non-directory filename part, without FQM suffix or uniquifying
1196 sequence numbers. The current buffer holds the raw message. The
1197 default function creates the slug based on the message subject, if
1198 any."
1199 :group 'feedmail-queue
1200 :type '(choice (const nil) function)
1204 (defcustom feedmail-queue-slug-suspect-regexp "[^a-z0-9-]+"
1205 "Regular expression for characters/substrings to be replaced.
1206 When feedmail creates a filename from a subject string, it puts hyphens
1207 in place of strings which may cause problems in filenames. By default,
1208 only alphanumeric and hyphen characters are kept, and all others are
1209 converted. In non-ASCII environments, it may be more helpful to
1210 tweak this regular expression to reflect local or personal language
1211 conventions. Substitutions are done repeatedly until the regular expression
1212 no longer matches to transformed string. Used by function
1213 feedmail-tidy-up-slug and indirectly by feedmail-queue-subject-slug-maker."
1214 :version "24.1"
1215 :group 'feedmail-queue
1216 :type 'string
1220 (defcustom feedmail-queue-default-file-slug t
1221 "Indicates what to use for subject-less messages when forming a file name.
1222 When feedmail queues a message, it creates a unique file name. By default,
1223 the file name is based in part on the subject of the message being queued.
1224 If there is no subject, consult this variable. See documentation for the
1225 function `feedmail-queue-subject-slug-maker'.
1227 If t, an innocuous default is used.
1229 If a string, it is used directly.
1231 If a function, it is called with no arguments from the buffer containing the raw
1232 text of the message. It must return a string (which may be empty).
1234 If the symbol 'ask, you will be prompted for a string in the mini-buffer.
1235 Filename completion is available so that you can inspect what's already been
1236 used, but feedmail will do further manipulation on the string you return, so
1237 it's not expected to be a complete filename."
1238 :group 'feedmail-queue
1239 :type '(choice (const :tag "Default" t) string function (const ask))
1243 (defcustom feedmail-queue-fqm-suffix ".fqm"
1244 "The FQM suffix used to distinguish feedmail queued message files.
1245 You probably want this to be a period followed by some letters and/or
1246 digits. The distinction is to be able to tell them from other random
1247 files that happen to be in the `feedmail-queue-directory' or
1248 `feedmail-queue-draft-directory'. By the way, FQM stands for feedmail
1249 queued message."
1250 :group 'feedmail-queue
1251 :type 'string
1255 (defcustom feedmail-nuke-buffer-after-queue nil
1256 "If non-nil, silently kill the buffer after a message is queued.
1257 You might like that since a side-effect of queueing the message is
1258 that its buffer name gets changed to the filename. That means that
1259 the buffer won't be reused for the next message you compose. If you
1260 are using VM for creating messages, you probably want to leave this
1261 nil, since VM has its own options for managing the recycling of
1262 message buffers."
1263 :group 'feedmail-queue
1264 :type 'boolean
1268 (defcustom feedmail-queue-auto-file-nuke nil
1269 "If non-nil, automatically delete queue files when a message is sent.
1270 Normally, feedmail will notice such files when you send a message in
1271 immediate mode (i.e., not when you're running the queue) and will ask if
1272 you want to delete them. Since the answer is usually yes, setting this
1273 variable to non-nil will tell feedmail to skip the prompt and just delete
1274 the file without bothering you."
1275 :group 'feedmail-queue
1276 :type 'boolean
1280 (defcustom feedmail-debug nil
1281 "If non-nil, blat a debug messages and such in the mini-buffer.
1282 This is intended as an aid to tracing what's going on but is probably
1283 of casual real use only to the feedmail developer."
1284 :version "24.1"
1285 :group 'feedmail-debug
1286 :type 'boolean
1290 (defcustom feedmail-debug-sit-for 0
1291 "Duration of pause after feedmail-debug messages.
1292 After some messages are divulged, it may be helpful to pause before
1293 something else obliterates them. This value controls the duration of
1294 the pause. If the value is nil or 0, the sit-for is not done, which
1295 has the effect of not pausing at all. Debug messages can be seen after
1296 the fact in the messages buffer."
1297 :version "24.1"
1298 :group 'feedmail-debug
1299 :type 'integer
1303 (defvar feedmail-queue-buffer-file-name nil
1304 "If non-nil, has the value normally expected of 'buffer-file-name'.
1305 You are not intended to set this to something in your configuration. Rather,
1306 you might programmatically set it to something via a hook or function
1307 advice or whatever. You might like to do this if you are using a mail
1308 composition program that eventually uses sendmail.el's 'mail-send'
1309 function to process the message. If there is a filename associated
1310 with the message buffer, 'mail-send' will ask you for confirmation.
1311 There's no trivial way to avoid it. It's unwise to just set the value
1312 of 'buffer-file-name' to nil because that will defeat feedmail's file
1313 management features. Instead, arrange for this variable to be set to
1314 the value of 'buffer-file-name' before setting that to nil. An easy way
1315 to do that would be with defadvice on 'mail-send' \(undoing the
1316 assignments in a later advice\).
1318 feedmail will pretend that 'buffer-file-name', if nil, has the value
1319 assigned of 'feedmail-queue-buffer-file-name' and carry out its normal
1320 activities. feedmail does not restore the non-nil value of
1321 'buffer-file-name'. For safe bookkeeping, the user should insure that
1322 feedmail-queue-buffer-file-name is restored to nil.
1324 Example 'defadvice' for mail-send:
1326 (defadvice mail-send (before feedmail-mail-send-before-advice activate)
1327 (setq feedmail-queue-buffer-file-name buffer-file-name)
1328 (setq buffer-file-name nil))
1330 (defadvice mail-send (after feedmail-mail-send-after-advice activate)
1331 (if feedmail-queue-buffer-file-name (setq buffer-file-name feedmail-queue-buffer-file-name))
1332 (setq feedmail-queue-buffer-file-name nil))
1335 ;; defvars to make byte-compiler happy(er)
1336 (defvar feedmail-error-buffer nil)
1337 (defvar feedmail-prepped-text-buffer nil)
1338 (defvar feedmail-raw-text-buffer nil)
1339 (defvar feedmail-address-list nil)
1342 (defvar feedmail-queue-runner-is-active nil
1343 "Non-nil means we're inside the logic of the queue-running loop.
1344 That is, iterating over all messages in the queue to send them. In
1345 that case, the value is the name of the queued message file currently
1346 being processed. This can be used for differentiating customized code
1347 for different scenarios. Users shouldn't set or change this
1348 variable, but may depend on its value as described here.")
1351 (defun feedmail-mail-send-hook-splitter ()
1352 "Facilitate dividing `mail-send-hook' things into queued and immediate cases.
1353 If you have `mail-send-hook' functions that should only be called for sending/
1354 queueing messages or only be called for the sending of queued messages, this is
1355 for you. Add this function to `mail-send-hook' with something like this:
1357 (add-hook 'mail-send-hook 'feedmail-mail-send-hook-splitter)
1359 Then add the functions you want called to either `feedmail-mail-send-hook-queued'
1360 or `feedmail-mail-send-hook', as appropriate. The distinction is that
1361 `feedmail-mail-send-hook' will be called when you send mail from a composition
1362 buffer (typically by typing C-c C-c), whether the message is sent immediately
1363 or placed in the queue or drafts directory. `feedmail-mail-send-hook-queued' is
1364 called when messages are being sent from the queue directory, typically via a
1365 call to `feedmail-run-the-queue'."
1366 (feedmail-say-debug ">in-> feedmail-mail-send-hook-splitter %s" feedmail-queue-runner-is-active)
1367 (if feedmail-queue-runner-is-active
1368 (run-hooks 'feedmail-mail-send-hook-queued)
1369 (run-hooks 'feedmail-mail-send-hook)))
1371 (defcustom feedmail-mail-send-hook nil
1372 "Hook run by `feedmail-mail-send-hook-splitter' for immediate mail.
1373 See documentation of `feedmail-mail-send-hook-splitter' for details."
1374 :type 'hook
1375 :group 'feedmail)
1377 (defcustom feedmail-mail-send-hook-queued nil
1378 "Hook run by `feedmail-mail-send-hook-splitter' for queued mail.
1379 See documentation of `feedmail-mail-send-hook-splitter' for details."
1380 :type 'hook
1381 :group 'feedmail)
1383 (defun feedmail-confirm-addresses-hook-example ()
1384 "An example of a `feedmail-last-chance-hook'.
1385 It shows the simple addresses and gets a confirmation. Use as:
1386 (setq feedmail-last-chance-hook 'feedmail-confirm-addresses-hook-example)."
1387 (save-window-excursion
1388 (display-buffer (set-buffer (get-buffer-create " F-C-A-H-E")))
1389 (erase-buffer)
1390 (insert (mapconcat 'identity feedmail-address-list " "))
1391 (if (not (y-or-n-p "How do you like them apples? "))
1392 (error "FQM: Sending...gave up in last chance hook"))))
1394 (defcustom feedmail-last-chance-hook nil
1395 "User's last opportunity to modify the message on its way out.
1396 When this hook runs, the current buffer is already the appropriate
1397 buffer. It has already had all the header prepping from the standard
1398 package. The next step after running the hook will be to save the
1399 message via FCC: processing. The hook might be interested in these:
1400 \(1) `feedmail-prepped-text-buffer' contains the header and body of the
1401 message, ready to go; (2) `feedmail-address-list' contains a list
1402 of simplified recipients of addresses which are to be given to the
1403 subprocess (the hook may change the list); (3) `feedmail-error-buffer'
1404 is an empty buffer intended to soak up errors for display to the user.
1405 If the hook allows interactive activity, the user should not send more
1406 mail while in the hook since some of the internal buffers will be
1407 reused and things will get confused. It's not necessary to
1408 arrange for the undoing of any changes you make to the buffer."
1409 :group 'feedmail-misc
1410 :type 'hook
1413 (defcustom feedmail-queue-express-hook nil
1414 "Chance to modify a message being sent directly to a queue.
1415 Run by feedmail-queue-express-to-queue and feedmail-queue-express-to-draft.
1416 For example, you might want to run vm-mime-encode-composition to take
1417 care of attachments. If you subsequently edit the message buffer, you
1418 can undo the encoding."
1419 :version "24.1"
1420 :group 'feedmail-queue
1421 :type 'hook
1424 (defcustom feedmail-before-fcc-hook nil
1425 "User's last opportunity to modify the message before Fcc action.
1426 It has already had all the header prepping from the standard package.
1427 The next step after running the hook will be to save the message via
1428 Fcc: processing. The hook might be interested in these: (1)
1429 `feedmail-prepped-text-buffer' contains the header and body of the
1430 message, ready to go; (2) `feedmail-address-list' contains a list of
1431 simplified recipients of addressees to whom the message was sent (3)
1432 `feedmail-error-buffer' is an empty buffer intended to soak up errors
1433 for display to the user. If the hook allows interactive activity, the
1434 user should not send more mail while in the hook since some of the
1435 internal buffers will be reused and things will get confused."
1436 :group 'feedmail-misc
1437 :type 'hook
1440 (defcustom feedmail-queue-runner-mode-setter
1441 (lambda (&optional arg) (mail-mode))
1442 "A function to set the proper mode of a message file.
1443 Called when the message is read back out of the queue directory with a single
1444 argument, the optional argument used in the call to
1445 `feedmail-run-the-queue' or `feedmail-run-the-queue-no-prompts'.
1447 Most people want `mail-mode', so the default value is an anonymous
1448 function which is just a wrapper to ignore the supplied argument when
1449 calling it, but here's your chance to have something different.
1450 If you are a VM user, you might like feedmail-vm-mail-mode, though you
1451 really don't need that (and it's not particularly well-tested).
1453 Called with funcall, not `call-interactively'."
1454 :group 'feedmail-queue
1455 :type 'function
1459 (defcustom feedmail-queue-alternative-mail-header-separator nil
1460 "Alternative header demarcation for queued messages.
1461 If you sometimes get alternative values for `mail-header-separator' in
1462 queued messages, set the value of this variable to whatever it is.
1463 For example, `rmail-resend' uses a `mail-header-separator' value of empty
1464 string (\"\") when you send/queue a message.
1466 When trying to send a queued message, if the value of this variable is
1467 non-nil, feedmail will first try to send the message using the value
1468 of `mail-header-separator'. If it can't find that, it will temporarily
1469 set `mail-header-separator' to the value of
1470 `feedmail-queue-alternative-mail-header-separator' and try again."
1471 :group 'feedmail-queue
1472 :type '(choice (const nil) string)
1476 (defcustom feedmail-queue-runner-message-sender
1477 (lambda (&optional arg) (mail-send))
1478 "Function to initiate sending a message file.
1479 Called for each message read back out of the queue directory with a
1480 single argument, the optional argument used in the call to
1481 `feedmail-run-the-queue' or `feedmail-run-the-queue-no-prompts'.
1482 Interactively, that argument will be the prefix argument.
1483 Most people want `mail-send' (bound to C-c C-s in mail-mode), but here's
1484 your chance to have something different. The default value is just a
1485 wrapper function which discards the optional argument and calls
1486 mail-send. If you are a VM user, you might like vm-mail-send, though
1487 you really don't need that. Called with funcall, not call-interactively."
1488 :version "24.1" ; changed default
1489 :group 'feedmail-queue
1490 :type 'function
1494 (defcustom feedmail-queue-runner-cleaner-upper
1495 (lambda (fqm-file &optional arg)
1496 (delete-file fqm-file)
1497 (if arg (feedmail-say-chatter "Nuked %s" fqm-file)))
1498 "Function that will be called after a message has been sent.
1499 Not called in the case of errors. This function is called with two
1500 arguments: the name of the message queue file for the message just sent,
1501 and the optional argument used in the call to `feedmail-run-the-queue'
1502 or `feedmail-run-the-queue-no-prompts' (prefix arg if interactive).
1503 In any case, the affiliated buffer is killed elsewhere, so don't do that
1504 inside this function. Return value is ignored.
1506 The default action is an anonymous function which gets rid of the file
1507 from the queue directory. With a non-nil second argument, a brief
1508 message is give for each file deleted. You could replace this
1509 function, for example, to archive all of your sent messages someplace
1510 \(though there are better ways to get that particular result\)."
1511 :group 'feedmail-queue
1512 :type 'function
1516 (defvar feedmail-is-a-resend nil
1517 "Non-nil means the message is a Resend (in the RFC-822 sense).
1518 This affects the composition of certain headers. feedmail sets this
1519 variable as soon as it starts prepping the message text buffer, so any
1520 user-supplied functions can rely on it. Users shouldn't set or change this
1521 variable, but may depend on its value as described here.")
1524 (defcustom feedmail-buffer-eating-function 'feedmail-buffer-to-binmail
1525 "Function used to send the prepped buffer to a subprocess.
1526 The function's three (mandatory) arguments are: (1) the buffer
1527 containing the prepped message; (2) a buffer where errors should be
1528 directed; and (3) a list containing the addresses individually as
1529 strings. Popular choices for this are `feedmail-buffer-to-binmail',
1530 `feedmail-buffer-to-smtpmail', `feedmail-buffer-to-sendmail', and
1531 `feedmail-buffer-to-smtp'. If you use the sendmail form, you probably
1532 want to set `feedmail-nuke-bcc' and/or `feedmail-nuke-resent-bcc to nil'.
1533 If you use the binmail form, check the value of `feedmail-binmail-template'."
1534 :group 'feedmail-misc
1535 :type 'function
1538 (defconst feedmail-binmail-gnulinuxish-template
1539 (concat
1540 "(echo From "
1541 (if (boundp 'user-login-name) user-login-name "feedmail")
1542 " ; cat -) | /usr/bin/rmail %s")
1543 "Good candidate for GNU/Linux systems and maybe others.
1544 You may need to modify this if your \"rmail\" is in a different place.
1545 For example, I hear that in some Debian systems, it's /usr/sbin/rmail.
1546 See feedmail-binmail-template documentation."
1549 (defcustom feedmail-binmail-template (if mail-interactive "/bin/mail %s"
1550 (if (file-exists-p "/bin/rmail")
1551 "/bin/rmail %s" "/bin/mail %s"))
1552 "Command template for the subprocess which will get rid of the mail.
1553 It can result in any command understandable by /bin/sh. Might not
1554 work at all in non-UNIX environments. The single '%s', if present,
1555 gets replaced by the space-separated, simplified list of addressees.
1556 Used in `feedmail-buffer-to-binmail' to form the shell command which
1557 will receive the contents of the prepped buffer as stdin. The default
1558 value uses /bin/rmail (if it exists) unless `mail-interactive' has been
1559 set non-nil.
1561 If you'd like your errors to come back as mail instead of immediately
1562 in a buffer, try /bin/rmail instead of /bin/mail. If /bin/rmail
1563 exists, this can be accomplished by keeping the default nil setting of
1564 `mail-interactive'. You might also like to consult local mail experts
1565 for any other interesting command line possibilities. Some versions
1566 of UNIX have an rmail program which behaves differently than
1567 /bin/rmail and complains if feedmail gives it a message on stdin. If
1568 you don't know about such things and if there is no local expert to
1569 consult, stick with /bin/mail or use one of the other buffer eating
1570 functions.
1572 The above description applies to \"classic\" UNIX /bin/mail and /bin/rmail.
1573 On most GNU/Linux systems and perhaps other places, /bin/mail behaves
1574 completely differently and shouldn't be used at all in this template.
1575 Instead of /bin/rmail, there is a /usr/bin/rmail, and it can be used
1576 with a wrapper. The wrapper is necessary because /usr/bin/rmail on such
1577 systems requires that the first line of the message appearing on standard
1578 input have a UNIX-style From_ postmark. If you have such a system, the
1579 wrapping can be accomplished by setting the value of `feedmail-binmail-template'
1580 to `feedmail-binmail-gnulinuxish-template'. You should then send some test
1581 messages to make sure it works as expected."
1582 :version "24.1" ; changed default
1583 :group 'feedmail-misc
1584 :type 'string
1588 ;; feedmail-buffer-to-binmail, feedmail-buffer-to-sendmail, and
1589 ;; feedmail-buffer-to-smtpmail are the only things provided for values
1590 ;; for the variable feedmail-buffer-eating-function. It's pretty easy
1591 ;; to write your own, though.
1592 (defun feedmail-buffer-to-binmail (prepped errors-to addr-listoid)
1593 "Function which actually calls /bin/mail as a subprocess.
1594 Feeds the buffer to it."
1595 (feedmail-say-debug ">in-> feedmail-buffer-to-binmail %s" addr-listoid)
1596 (set-buffer prepped)
1597 (apply
1598 'call-process-region
1599 (append (list (point-min) (point-max) "/bin/sh" nil errors-to nil "-c"
1600 (format feedmail-binmail-template
1601 (mapconcat 'identity addr-listoid " "))))))
1604 (defvar sendmail-program)
1606 (defun feedmail-buffer-to-sendmail (prepped errors-to addr-listoid)
1607 "Function which actually calls sendmail as a subprocess.
1608 Feeds the buffer to it. Probably has some flaws for Resent-* and other
1609 complicated cases. Takes addresses from message headers and
1610 might disappoint you with BCC: handling. In case of odd results, consult
1611 local gurus."
1612 (require 'sendmail)
1613 (feedmail-say-debug ">in-> feedmail-buffer-to-sendmail %s" addr-listoid)
1614 (set-buffer prepped)
1615 (apply 'call-process-region
1616 (append (list (point-min) (point-max) sendmail-program
1617 nil errors-to nil "-oi" "-t")
1618 ;; provide envelope "from" to sendmail; results will vary
1619 (if feedmail-sendmail-f-doesnt-sell-me-out
1620 (list "-f" user-mail-address))
1621 ;; These mean "report errors by mail" and "deliver in background".
1622 (if (null mail-interactive) '("-oem" "-odb")))))
1624 (declare-function smtpmail-via-smtp "smtpmail"
1625 (recipient smtpmail-text-buffer &optional ask-for-password))
1626 (defvar smtpmail-smtp-server)
1628 ;; provided by jam@austin.asc.slb.com (James A. McLaughlin);
1629 ;; simplified by WJC after more feedmail development;
1630 ;; idea (but not implementation) of copying smtpmail trace buffer to
1631 ;; feedmail error buffer from:
1632 ;; Mon 14-Oct-1996; Douglas Gray Stephens
1633 ;; modified to insert error for displaying
1634 (defun feedmail-buffer-to-smtpmail (prepped errors-to addr-listoid)
1635 "Function which actually calls `smtpmail-via-smtp' to send buffer as e-mail."
1636 ;; I'm not sure smtpmail.el is careful about the following
1637 ;; return value, but it also uses it internally, so I will fear
1638 ;; no evil.
1639 (feedmail-say-debug ">in-> feedmail-buffer-to-smtpmail %s" addr-listoid)
1640 (require 'smtpmail)
1641 (let ((result (smtpmail-via-smtp addr-listoid prepped)))
1642 (when result
1643 (set-buffer errors-to)
1644 (insert "Send via smtpmail failed: %s" result)
1645 (let ((case-fold-search t)
1646 ;; don't be overconfident about the name of the trace buffer
1647 (tracer (concat "trace.*smtp.*" (regexp-quote smtpmail-smtp-server))))
1648 (mapcar
1649 (lambda (buffy)
1650 (if (string-match tracer (buffer-name buffy))
1651 (progn
1652 (insert "SMTP Trace from " (buffer-name buffy) "\n---------------")
1653 (insert-buffer-substring buffy)
1654 (insert "\n\n"))))
1655 (buffer-list))))))
1657 (declare-function smtp-via-smtp "ext:smtp" (sender recipients smtp-text-buffer))
1658 (defvar smtp-server)
1660 ;; FLIM's smtp.el pointed out to me by Kenichi Handa <handa@etl.go.jp>
1661 (defun feedmail-buffer-to-smtp (prepped errors-to addr-listoid)
1662 "Function which actually calls smtp-via-smtp to send buffer as e-mail."
1663 (feedmail-say-debug ">in-> feedmail-buffer-to-smtp %s" addr-listoid)
1664 (require 'smtp)
1665 (if (not (smtp-via-smtp user-mail-address addr-listoid prepped))
1666 (progn
1667 (set-buffer errors-to)
1668 (insert "Send via smtp failed. Probable SMTP protocol error.\n")
1669 (insert "Look for details below or in the *Messages* buffer.\n\n")
1670 (let ((case-fold-search t)
1671 ;; don't be overconfident about the name of the trace buffer
1672 (tracer (concat "trace.*smtp.*" (regexp-quote smtp-server))))
1673 (mapcar
1674 (lambda (buffy)
1675 (if (string-match tracer (buffer-name buffy))
1676 (progn
1677 (insert "SMTP Trace from " (buffer-name buffy) "\n---------------")
1678 (insert-buffer-substring buffy)
1679 (insert "\n\n"))))
1680 (buffer-list))))))
1682 ;; just a place to park a docstring
1683 (defconst feedmail-fiddle-plex-blurb nil
1684 "A fiddle-plex is a concise way of specifying header field fiddling.
1685 It is a list of up to 4 elements: NAME, VALUE, ACTION, FOLDING. The element
1686 VALUE can also be a list sometimes.
1688 NAME is the name of the header field to be fiddled with. Although case
1689 doesn't matter in looking for headers, case of NAME is preserved when a header
1690 is inserted via fiddling. It shouldn't include the trailing colon.
1692 VALUE is either nil, a simple string, a function returning nil or a string, or,
1693 as described below for ACTION `combine', a list of up to three values.
1695 ACTION describes the nature of the fiddling to be done. Possibilities
1696 for ACTION (default is `supplement'):
1698 `supplement' Leave other like fields as-is, insert this one.
1700 `replace' Delete other like fields, if any, and insert this one.
1702 `create' Insert this one only if no like field exists.
1704 `combine' Combine aggregate values of like fields with this one.
1705 In this case, VALUE has a special form. It is a list
1706 of three items: VAL-PRE, VAL-LIKE, and VAL-POST.
1707 VAL-PRE and VAL-POST are strings or nil. VAL-LIKE may
1708 be either a string or a function (it may also be nil,
1709 but there's not much point to that).
1711 Values of like header fields are aggregated, leading and
1712 trailing whitespace is removed, and embedded
1713 whitespace is left as-is. If there are no like
1714 fields, or the aggregate value is an empty string,
1715 VAL-LIKE is not used. Else, if VAL-LIKE is a function,
1716 it is called with two arguments: NAME and the
1717 aggregate like values. Else, if VAL-LIKE is a string, it is
1718 used as a format string where a single \%s will be
1719 replaced by the aggregate values of like fields.
1721 VAL-PRE, the results of using VAL-LIKE, and VAL-POST
1722 are concatenated, and the result, if not nil and not
1723 an empty string, is used as the new value for the
1724 field. Although this description sounds a bit
1725 complicated, the idea is to provide a mechanism for
1726 combining the old value with a new value in a flexible
1727 way. For example, if you wanted to add a new value to
1728 an existing header field by adding a semi-colon and
1729 then starting the new value on a continuation line,
1730 you might specify this:
1732 (nil \"%s;\\n\\t\" \"This is my new value\")
1734 FOLDING can be nil, in which case VALUE is used as-is. If FOLDING is
1735 non-nil, feedmail \"smart filling\" is done on VALUE just before
1736 insertion.")
1738 (declare-function vm-mail "ext:vm" (&optional to subject))
1740 (defun feedmail-vm-mail-mode (&optional arg)
1741 "Make something like a buffer that has been created via `vm-mail'.
1742 The optional argument is ignored and is just for argument compatibility with
1743 `feedmail-queue-runner-mode-setter'. This function is suitable for being
1744 applied to a file after you've just read it from disk: for example, a
1745 feedmail FQM message file from a queue. You could use something like
1746 this:
1748 \(setq auto-mode-alist \(cons \'\(\"\\\\.fqm$\" . feedmail-vm-mail-mode\) auto-mode-alist\)\)
1750 (feedmail-say-debug ">in-> feedmail-vm-mail-mode")
1751 (let ((the-buf (current-buffer)))
1752 (vm-mail)
1753 (delete-region (point-min) (point-max))
1754 (insert-buffer-substring the-buf)
1755 (setq buffer-file-name (buffer-file-name the-buf))
1756 (set-buffer-modified-p (buffer-modified-p the-buf))
1757 ;; For some versions of emacs, saving the message to a queue
1758 ;; triggers running the mode function on the buffer, and that
1759 ;; leads (through a series of events I don't really understand)
1760 ;; to this function being called while the buffer is still
1761 ;; marked modified even though it is in the process of being
1762 ;; saved. I guess the function gets called during the renaming
1763 ;; that takes place en route to the save.
1765 ;; This clearing of the marker probably wastes a buffer copy
1766 ;; but it's easy to do and more reliable than figuring out what
1767 ;; each variant of emacs does in this strange case.
1768 (with-current-buffer the-buf
1769 (set-buffer-modified-p nil))
1770 (kill-buffer the-buf)
1773 ;;;###autoload
1774 (defun feedmail-send-it ()
1775 "Send the current mail buffer using the Feedmail package.
1776 This is a suitable value for `send-mail-function'. It can be used
1777 with various lower-level mechanisms to provide features such as queueing."
1778 (feedmail-say-debug ">in-> feedmail-send-it")
1779 (save-excursion
1780 (let ((bfn-jiggle nil))
1781 ;; if buffer-file-name is nil, temporarily use the stashed value
1782 (if (and (not buffer-file-name) feedmail-queue-buffer-file-name)
1783 (setq buffer-file-name feedmail-queue-buffer-file-name
1784 bfn-jiggle t))
1785 ;; avoid matching trouble over slash vs backslash by getting canonical
1786 (if feedmail-queue-directory
1787 (setq feedmail-queue-directory (expand-file-name feedmail-queue-directory)))
1788 (if feedmail-queue-draft-directory
1789 (setq feedmail-queue-draft-directory (expand-file-name feedmail-queue-draft-directory)))
1790 (if (not feedmail-enable-queue) (feedmail-send-it-immediately-wrapper)
1791 ;; else, queuing is enabled, should we ask about it or just do it?
1792 (if feedmail-ask-before-queue
1793 (funcall (feedmail-queue-send-edit-prompt))
1794 (feedmail-dump-message-to-queue feedmail-queue-directory 'after-queue)))
1795 ;; put this back
1796 (if bfn-jiggle (setq feedmail-queue-buffer-file-name buffer-file-name))
1799 (defun feedmail-message-action-send ()
1800 ;; hooks can make this take a while so clear the prompt
1801 (feedmail-say-debug ">in-> feedmail-message-action-send")
1802 (message "FQM: Immediate send...")
1803 (feedmail-send-it-immediately-wrapper))
1806 ;; From a VM mailing list discussion and some suggestions from Samuel Mikes <smikes@alumni.hmc.edu>
1807 (defun feedmail-queue-express-to-queue ()
1808 "Send message directly to the queue, with a minimum of fuss and bother."
1809 (interactive)
1810 (feedmail-say-debug ">in-> feedmail-queue-express-to-queue")
1811 (run-hooks 'feedmail-queue-express-hook)
1812 (let ((feedmail-enable-queue t)
1813 (feedmail-ask-before-queue nil)
1814 (feedmail-queue-reminder-alist nil)
1815 (feedmail-queue-chatty-sit-for 0))
1816 (feedmail-send-it)
1821 (defun feedmail-queue-express-to-draft ()
1822 "Send message directly to the draft queue, with a minimum of fuss and bother."
1823 (interactive)
1824 (feedmail-say-debug ">in-> feedmail-queue-express-to-draft")
1825 (let ((feedmail-queue-directory feedmail-queue-draft-directory))
1826 (feedmail-queue-express-to-queue)
1831 (defun feedmail-message-action-send-strong ()
1832 (feedmail-say-debug ">in-> feedmail-message-action-send-strong")
1833 (let ((feedmail-confirm-outgoing nil)) (feedmail-message-action-send)))
1836 (defun feedmail-message-action-edit ()
1837 (feedmail-say-debug ">in-> feedmail-message-action-edit")
1838 (error "FQM: Message not queued; returning to edit"))
1841 (defun feedmail-message-action-draft ()
1842 (feedmail-say-debug ">in-> feedmail-message-action-draft")
1843 (feedmail-dump-message-to-queue feedmail-queue-draft-directory 'after-draft))
1846 (defun feedmail-message-action-draft-strong ()
1847 (feedmail-say-debug ">in-> feedmail-message-action-draft-strong")
1848 (let ((buffer-file-name nil))
1849 (feedmail-message-action-draft)))
1852 (defun feedmail-message-action-queue ()
1853 (feedmail-say-debug ">in-> feedmail-message-action-queue")
1854 (feedmail-dump-message-to-queue feedmail-queue-directory 'after-queue))
1857 (defun feedmail-message-action-queue-strong ()
1858 (feedmail-say-debug ">in-> feedmail-message-action-queue-strong")
1859 (let ((buffer-file-name nil))
1860 (feedmail-message-action-queue)))
1863 (defun feedmail-message-action-toggle-spray ()
1864 (feedmail-say-debug ">in-> feedmail-message-action-toggle-spray")
1865 (let ((feedmail-enable-spray (not feedmail-enable-spray)))
1866 (if feedmail-enable-spray
1867 (message "FQM: For this message, spray toggled ON")
1868 (message "FQM: For this message, spray toggled OFF"))
1869 (sit-for 3)
1870 ;; recursion, but harmless
1871 (feedmail-send-it)))
1874 (defconst feedmail-p-h-b-n "*FQM Help*")
1876 (defun feedmail-message-action-help ()
1877 (feedmail-say-debug ">in-> feedmail-message-action-help")
1878 (let ((d-string " ")
1879 (fqm-help (get-buffer feedmail-p-h-b-n)))
1880 (if (stringp feedmail-ask-before-queue-default)
1881 (setq d-string feedmail-ask-before-queue-default)
1882 (setq d-string (char-to-string feedmail-ask-before-queue-default)))
1883 (if (and fqm-help (get-buffer-window fqm-help))
1884 (feedmail-scroll-buffer 'up fqm-help)
1885 (feedmail-message-action-help-blat d-string))
1886 ;; recursive, but no worries (it goes deeper on user action)
1887 (feedmail-send-it)))
1889 (defun feedmail-message-action-help-blat (d-string)
1890 (feedmail-say-debug ">in-> feedmail-message-action-help-blat")
1891 (with-output-to-temp-buffer feedmail-p-h-b-n
1892 (princ "You're dispatching a message and feedmail queuing is enabled.
1893 Typing ? again will normally scroll this help buffer.
1895 Choices:
1896 q QUEUE for later sending \(via feedmail-run-the-queue\)
1897 Q QUEUE! like \"q\", but always make a new file
1898 i IMMEDIATELY send this \(but not the other queued messages\)
1899 I IMMEDIATELY! like \"i\", but skip following confirmation prompt
1900 d DRAFT queue in the draft directory
1901 D DRAFT! like \"d\", but always make a new file
1902 e EDIT return to the message edit buffer \(don't send or queue\)
1903 * SPRAY toggle spray mode \(individual message transmissions\)
1904 > SCROLL UP scroll message up \(toward end of message\)
1905 < SCROLL DOWN scroll message down \(toward beginning of message\)
1906 ? HELP show or scroll this help buffer
1908 Synonyms:
1909 s SEND immediately \(same as \"i\"\)
1910 S SEND! immediately \(same as \"I\"\)
1911 r ROUGH draft \(same as \"d\"\)
1912 R ROUGH! draft \(same as \"D\"\)
1913 n NOPE didn't mean it \(same as \"e\"\)
1914 y YUP do the default behavior \(same as \"C-m\"\)
1915 SPC SCROLL UP \(same as \">\"\)
1917 The user-configurable default is currently \"")
1918 (princ d-string)
1919 (princ "\". For other possibilities,
1920 see the variable feedmail-prompt-before-queue-user-alist.
1922 (and (stringp feedmail-prompt-before-queue-help-supplement)
1923 (princ feedmail-prompt-before-queue-help-supplement))
1924 (with-current-buffer standard-output
1925 (if (fboundp 'help-mode) (help-mode)))))
1928 (defun feedmail-message-action-scroll-up ()
1929 (feedmail-say-debug ">in-> feedmail-message-action-scroll-up")
1930 (feedmail-scroll-buffer 'up)
1931 ;; recursive, but no worries (it goes deeper on user action)
1932 (feedmail-send-it))
1935 (defun feedmail-message-action-scroll-down ()
1936 (feedmail-say-debug ">in-> feedmail-message-action-scroll-down")
1937 (feedmail-scroll-buffer 'down)
1938 ;; recursive, but no worries (it goes deeper on user action)
1939 (feedmail-send-it))
1942 ;;;###autoload
1943 (defun feedmail-run-the-queue-no-prompts (&optional arg)
1944 "Like `feedmail-run-the-queue', but suppress confirmation prompts."
1945 (interactive "p")
1946 (feedmail-say-debug ">in-> feedmail-run-the-queue-no-prompts")
1947 (let ((feedmail-confirm-outgoing nil)) (feedmail-run-the-queue arg)))
1949 ;;;###autoload
1950 (defun feedmail-run-the-queue-global-prompt (&optional arg)
1951 "Like `feedmail-run-the-queue', but with a global confirmation prompt.
1952 This is generally most useful if run non-interactively, since you can
1953 bail out with an appropriate answer to the global confirmation prompt."
1954 (interactive "p")
1955 (feedmail-say-debug ">in-> feedmail-run-the-queue-global-prompts")
1956 (let ((feedmail-queue-runner-confirm-global t)) (feedmail-run-the-queue arg)))
1958 ;;;###autoload
1959 (defun feedmail-run-the-queue (&optional arg)
1960 "Visit each message in the feedmail queue directory and send it out.
1961 Return value is a list of three things: number of messages sent, number of
1962 messages skipped, and number of non-message things in the queue (commonly
1963 backup file names and the like)."
1964 (interactive "p")
1965 (feedmail-say-debug ">in-> feedmail-run-the-queue")
1966 ;; avoid matching trouble over slash vs backslash by getting canonical
1967 (if feedmail-queue-directory
1968 (setq feedmail-queue-directory (expand-file-name feedmail-queue-directory)))
1969 (if feedmail-queue-draft-directory
1970 (setq feedmail-queue-draft-directory (expand-file-name feedmail-queue-draft-directory)))
1971 (let* ((maybe-file)
1972 (qlist (feedmail-look-at-queue-directory feedmail-queue-directory))
1973 (dlist (feedmail-look-at-queue-directory feedmail-queue-draft-directory))
1974 (q-cnt (nth 0 qlist))
1975 (q-oth (nth 1 qlist))
1976 (d-cnt (nth 0 dlist))
1977 (d-oth (nth 1 dlist))
1978 (messages-sent 0)
1979 (messages-skipped 0)
1980 (blobby-buffer)
1981 (already-buffer)
1982 (do-the-run t)
1983 (list-of-possible-fqms))
1984 (if (and (> q-cnt 0) feedmail-queue-runner-confirm-global)
1985 (setq do-the-run
1986 (if (fboundp 'y-or-n-p-with-timeout)
1987 (y-or-n-p-with-timeout (format "FQM: Draft: %dm+%d, Queue: %dm+%d; run the queue? "
1988 d-cnt d-oth q-cnt q-oth)
1989 5 nil)
1990 (y-or-n-p (format "FQM: Draft: %dm+%d, Queue: %dm+%d; run the queue? "
1991 d-cnt d-oth q-cnt q-oth))
1993 (if (not do-the-run)
1994 (setq messages-skipped q-cnt)
1995 (save-window-excursion
1996 (setq list-of-possible-fqms (directory-files feedmail-queue-directory t))
1997 (if feedmail-queue-run-orderer
1998 (setq list-of-possible-fqms (funcall feedmail-queue-run-orderer list-of-possible-fqms)))
1999 (mapc
2000 (lambda (blobby)
2001 (setq maybe-file (expand-file-name blobby feedmail-queue-directory))
2002 (cond
2003 ((file-directory-p maybe-file) nil) ; don't care about subdirs
2004 ((feedmail-fqm-p blobby)
2005 (setq blobby-buffer (generate-new-buffer (concat "FQM " blobby)))
2006 (setq already-buffer
2007 (if (fboundp 'find-buffer-visiting) ; missing from XEmacs
2008 (find-buffer-visiting maybe-file)
2009 (get-file-buffer maybe-file)))
2010 (if (and already-buffer (buffer-modified-p already-buffer))
2011 (save-window-excursion
2012 (display-buffer (set-buffer already-buffer))
2013 (if (fboundp 'y-or-n-p-with-timeout)
2014 ;; make a guess that the user just forgot to save
2015 (if (y-or-n-p-with-timeout (format "FQM: Visiting %s; save before send? " blobby) 10 t)
2016 (save-buffer))
2017 (if (y-or-n-p (format "FQM: Visiting %s; save before send? " blobby))
2018 (save-buffer))
2021 (set-buffer blobby-buffer)
2022 (setq buffer-offer-save nil)
2023 (buffer-disable-undo blobby-buffer)
2024 (insert-file-contents-literally maybe-file)
2025 (goto-char (point-min))
2026 ;; if at least two line-endings with CRLF, translate the file
2027 (if (looking-at ".*\r\n.*\r\n")
2028 (while (search-forward "\r\n" nil t)
2029 (replace-match "\n" nil t)))
2030 (funcall feedmail-queue-runner-mode-setter arg)
2031 (condition-case signal-stuff ; don't give up the loop if user skips some
2032 (let ((feedmail-enable-queue nil)
2033 (feedmail-queue-runner-is-active maybe-file))
2034 ;; if can't find EOH, this is no message!
2035 (unless (feedmail-find-eoh t)
2036 (feedmail-say-chatter "Skipping %s; no mail-header-separator" maybe-file)
2037 (error "FQM: you should never see this message"))
2038 (feedmail-say-debug "Prepping %s" maybe-file)
2039 ;; the catch is a way out for users to voluntarily skip sending a message
2040 (catch 'skip-me-q (funcall feedmail-queue-runner-message-sender arg))
2041 (set-buffer blobby-buffer)
2042 (if (buffer-modified-p) ; still modified, means wasn't sent
2043 (progn
2044 (setq messages-skipped (1+ messages-skipped))
2045 (feedmail-say-chatter "%s wasn't sent by %s" maybe-file feedmail-buffer-eating-function))
2046 (setq messages-sent (1+ messages-sent))
2047 (funcall feedmail-queue-runner-cleaner-upper maybe-file arg)
2048 (if (and already-buffer (not (file-exists-p maybe-file)))
2049 ;; we have gotten rid of the file associated with the
2050 ;; buffer, so update the buffer's notion of that
2051 (with-current-buffer already-buffer
2052 (setq buffer-file-name nil)))))
2053 ;; the handler for the condition-case
2054 (error (setq messages-skipped (1+ messages-skipped))
2055 (ding t)
2056 (message "FQM: Trapped '%s', message left in queue." (car signal-stuff))
2057 (sit-for 3)
2058 (message "FQM: Trap details: \"%s\""
2059 (mapconcat 'identity (cdr signal-stuff) "\" \""))
2060 (sit-for 3)))
2061 (kill-buffer blobby-buffer)
2062 (feedmail-say-chatter
2063 "%d to go, %d sent, %d skipped (%d other files ignored)"
2064 (- q-cnt messages-sent messages-skipped)
2065 messages-sent messages-skipped q-oth)
2067 list-of-possible-fqms)))
2068 (if feedmail-queue-chatty
2069 (progn
2070 (feedmail-say-chatter "%d sent, %d skipped (%d other files ignored)"
2071 messages-sent messages-skipped q-oth)
2072 (feedmail-queue-reminder 'after-run)
2073 (sit-for feedmail-queue-chatty-sit-for)))
2074 (list messages-sent messages-skipped q-oth)))
2077 ;;;###autoload
2078 (defun feedmail-queue-reminder (&optional what-event)
2079 "Perform some kind of reminder activity about queued and draft messages.
2080 Called with an optional symbol argument which says what kind of event
2081 is triggering the reminder activity. The default is 'on-demand, which
2082 is what you typically would use if you were putting this in your Emacs start-up
2083 or mail hook code. Other recognized values for WHAT-EVENT (these are passed
2084 internally by feedmail):
2086 after-immediate (a message has just been sent in immediate mode)
2087 after-queue (a message has just been queued)
2088 after-draft (a message has just been placed in the draft directory)
2089 after-run (the queue has just been run, possibly sending messages)
2091 WHAT-EVENT is used as a key into the table `feedmail-queue-reminder-alist'. If
2092 the associated value is a function, it is called without arguments and is expected
2093 to perform the reminder activity. You can supply your own reminder functions
2094 by redefining `feedmail-queue-reminder-alist'. If you don't want any reminders,
2095 you can set `feedmail-queue-reminder-alist' to nil."
2096 (interactive "p")
2097 (feedmail-say-debug ">in-> feedmail-queue-reminder %s" what-event)
2098 (let ((key (if (and what-event (symbolp what-event)) what-event 'on-demand)) entry reminder)
2099 (setq entry (assoc key feedmail-queue-reminder-alist))
2100 (setq reminder (cdr entry))
2101 (if (fboundp reminder) (funcall reminder)))
2105 (defun feedmail-queue-reminder-brief ()
2106 "Brief display of draft and queued message counts in minibuffer."
2107 (interactive)
2108 (feedmail-say-debug ">in-> feedmail-queue-reminder-brief")
2109 (let (q-cnt d-cnt q-lis d-lis)
2110 (setq q-lis (feedmail-look-at-queue-directory feedmail-queue-directory))
2111 (setq d-lis (feedmail-look-at-queue-directory feedmail-queue-draft-directory))
2112 (setq q-cnt (car q-lis))
2113 (setq d-cnt (car d-lis))
2114 (if (or (> q-cnt 0) (> d-cnt 0))
2115 (progn
2116 (message "FQM: [D: %d, Q: %d]" d-cnt q-cnt))))
2120 (defun feedmail-queue-reminder-medium ()
2121 "Verbose display of draft and queued message counts in minibuffer."
2122 (interactive)
2123 (feedmail-say-debug ">in-> feedmail-queue-reminder-medium")
2124 (let (q-cnt d-cnt q-oth d-oth q-lis d-lis)
2125 (setq q-lis (feedmail-look-at-queue-directory feedmail-queue-directory))
2126 (setq d-lis (feedmail-look-at-queue-directory feedmail-queue-draft-directory))
2127 (setq q-cnt (car q-lis))
2128 (setq d-cnt (car d-lis))
2129 (setq q-oth (nth 1 q-lis))
2130 (setq d-oth (nth 1 d-lis))
2131 (if (or (> q-cnt 0) (> d-cnt 0))
2132 (progn
2133 (message "FQM: Draft: %dm+%d in \"%s\", Queue: %dm+%d in \"%s\""
2134 d-cnt d-oth (file-name-nondirectory feedmail-queue-draft-directory)
2135 q-cnt q-oth (file-name-nondirectory feedmail-queue-directory)))))
2139 (defun feedmail-queue-send-edit-prompt ()
2140 "Ask whether to queue, send immediately, or return to editing a message, etc."
2141 (feedmail-say-debug ">in-> feedmail-queue-send-edit-prompt")
2142 (feedmail-queue-send-edit-prompt-inner
2143 feedmail-ask-before-queue-default
2144 feedmail-ask-before-queue-prompt
2145 feedmail-ask-before-queue-reprompt
2146 'feedmail-message-action-help
2147 feedmail-prompt-before-queue-standard-alist
2148 feedmail-prompt-before-queue-user-alist
2151 (defun feedmail-queue-runner-prompt ()
2152 "Ask whether to queue, send immediately, or return to editing a message, etc."
2153 (feedmail-say-debug ">in-> feedmail-queue-runner-prompt")
2154 (feedmail-queue-send-edit-prompt-inner
2155 feedmail-ask-before-queue-default
2156 feedmail-ask-before-queue-prompt
2157 feedmail-ask-before-queue-reprompt
2158 'feedmail-message-action-help
2159 feedmail-prompt-before-queue-standard-alist
2160 feedmail-prompt-before-queue-user-alist
2162 (defun feedmail-queue-send-edit-prompt-inner (default prompt reprompt helper
2163 standard-alist user-alist)
2164 (feedmail-say-debug ">in-> feedmail-queue-send-edit-prompt-inner")
2165 ;; Some implementation ideas here came from the userlock.el code
2166 (or defining-kbd-macro (discard-input))
2167 (save-window-excursion
2168 (let ((answer) (d-char) (d-string " "))
2169 (if (stringp default)
2170 (progn
2171 (setq d-char (string-to-char default)
2172 d-string default))
2173 (setq d-string (char-to-string default))
2174 (setq d-char default)
2176 (while (null answer)
2177 (message prompt d-string)
2178 (let ((user-sez
2179 (let ((inhibit-quit t) (cursor-in-echo-area t) (echo-keystrokes 0))
2180 (read-char-exclusive))))
2181 (if (= user-sez help-char)
2182 (setq answer '(^ . helper))
2183 (if (or (eq user-sez ?\C-m) (eq user-sez ?\C-j) (eq user-sez ?y))
2184 (setq user-sez d-char))
2185 ;; these char-to-int things are because of some
2186 ;; incomprehensible difference between the two in
2187 ;; byte-compiled stuff between Emacs and XEmacs
2188 ;; (well, I'm sure someone could comprehend it,
2189 ;; but I say 'uncle')
2190 (setq answer (or (assoc user-sez user-alist)
2191 (and (fboundp 'char-to-int)
2192 (assoc (char-to-int user-sez) user-alist))
2193 (assoc user-sez standard-alist)
2194 (and (fboundp 'char-to-int)
2195 (assoc (char-to-int user-sez) standard-alist))))
2196 (if (or (null answer) (null (cdr answer)))
2197 (progn
2198 (beep)
2199 (message reprompt d-string)
2200 (sit-for 3)))
2202 (cdr answer)
2205 (defun feedmail-scroll-buffer (direction &optional buffy)
2206 ;; scrolling fun
2207 ;; emacs convention is that scroll-up moves text up, window down
2208 (feedmail-say-debug ">in-> feedmail-scroll-buffer %s" direction)
2209 (save-selected-window
2210 (let ((signal-error-on-buffer-boundary nil)
2211 (fqm-window (display-buffer (if buffy buffy (current-buffer)))))
2212 (select-window fqm-window)
2213 (if (eq direction 'up)
2214 (if (pos-visible-in-window-p (point-max) fqm-window)
2215 ;; originally just (goto-char (point-min)), but
2216 ;; pos-visible-in-window-p seems oblivious to that
2217 (scroll-down 999999)
2218 (scroll-up))
2219 (if (pos-visible-in-window-p (point-min) fqm-window)
2220 (scroll-up 999999)
2221 (scroll-down))))))
2224 (defun feedmail-look-at-queue-directory (queue-directory)
2225 "Find out some things about a queue directory.
2226 Result is a list containing a count of queued messages in the
2227 directory, a count of other files in the directory, and a high water
2228 mark for prefix sequence numbers. Subdirectories are not included in
2229 the counts."
2230 (feedmail-say-debug ">in-> feedmail-look-at-queue-directory %s" queue-directory)
2231 (let ((q-cnt 0) (q-oth 0) (high-water 0) (blobbet))
2232 ;; iterate, counting things we find along the way in the directory
2233 (if (file-directory-p queue-directory)
2234 (mapc
2235 (lambda (blobby)
2236 (cond
2237 ((file-directory-p blobby) nil) ; don't care about subdirs
2238 ((feedmail-fqm-p blobby)
2239 (setq blobbet (file-name-nondirectory blobby))
2240 (if (string-match "^[0-9][0-9][0-9]-" blobbet)
2241 (let ((water-mark))
2242 (setq water-mark (string-to-number (substring blobbet 0 3)))
2243 (if (> water-mark high-water) (setq high-water water-mark))))
2244 (setq q-cnt (1+ q-cnt)))
2245 (t (setq q-oth (1+ q-oth)))
2247 (directory-files queue-directory t)))
2248 (list q-cnt q-oth high-water)))
2250 (defun feedmail-tidy-up-slug (slug)
2251 "Utility for mapping out suspect characters in a potential filename."
2252 (feedmail-say-debug ">in-> feedmail-tidy-up-slug %s" slug)
2253 ;; even programmers deserve a break sometimes, so cover nil for them
2254 (if (null slug) (setq slug ""))
2255 ;; replace all non-alphanumerics with hyphen for safety
2256 (while (string-match feedmail-queue-slug-suspect-regexp slug) (setq slug (replace-match "-" nil nil slug)))
2257 ;; collapse multiple hyphens to one
2258 (while (string-match "--+" slug) (setq slug (replace-match "-" nil nil slug)))
2259 ;; for tidiness, peel off leading hyphens
2260 (if (string-match "^-*" slug) (setq slug (replace-match "" nil nil slug)))
2261 ;; for tidiness, peel off trailing hyphens
2262 (if (string-match "-*$" slug) (setq slug (replace-match "" nil nil slug)))
2263 slug
2266 (defun feedmail-queue-subject-slug-maker (&optional queue-directory)
2267 "Create a name for storing the message in the queue.
2268 Optional argument QUEUE-DIRECTORY specifies into which directory the
2269 file will be placed. The name is based on the Subject: header (if
2270 there is one). If there is no subject,
2271 `feedmail-queue-default-file-slug' is consulted. Special characters are
2272 mapped to mostly alphanumerics for safety."
2273 (feedmail-say-debug ">in-> feedmail-queue-subject-slug-maker %s" queue-directory)
2274 (let ((eoh-marker) (case-fold-search t) (subject "") (s-point))
2275 (setq eoh-marker (feedmail-find-eoh))
2276 (goto-char (point-min))
2277 ;; get raw subject value (first line, anyhow)
2278 (if (re-search-forward "^Subject:" eoh-marker t)
2279 (progn (setq s-point (point))
2280 (end-of-line)
2281 (setq subject (buffer-substring-no-properties s-point (point)))))
2282 (setq subject (feedmail-tidy-up-slug subject))
2283 (if (zerop (length subject))
2284 (setq subject
2285 (cond
2286 ((stringp feedmail-queue-default-file-slug) feedmail-queue-default-file-slug)
2287 ((fboundp feedmail-queue-default-file-slug)
2288 (save-excursion (funcall feedmail-queue-default-file-slug)))
2289 ((eq feedmail-queue-default-file-slug 'ask)
2290 (file-name-nondirectory
2291 (read-file-name "FQM: Message filename slug? "
2292 (file-name-as-directory queue-directory) subject nil subject)))
2293 (t "no subject"))
2295 ;; one more time, with feeling
2296 (feedmail-tidy-up-slug subject)
2300 (defun feedmail-create-queue-filename (queue-directory)
2301 (feedmail-say-debug ">in-> feedmail-create-queue-filename %s" queue-directory)
2302 (let ((slug "wjc"))
2303 (cond
2304 (feedmail-queue-slug-maker
2305 (save-excursion (setq slug (funcall feedmail-queue-slug-maker queue-directory))))
2306 (feedmail-ask-for-queue-slug
2307 (setq slug (file-name-nondirectory
2308 (read-file-name (concat "FQM: Message filename slug? [" slug "]? ")
2309 (file-name-as-directory queue-directory) slug nil slug))))
2311 (setq slug (feedmail-tidy-up-slug slug))
2312 (setq slug (format "%03d-%s" (1+ (nth 2 (feedmail-look-at-queue-directory queue-directory))) slug))
2313 (concat
2314 (expand-file-name slug queue-directory)
2315 feedmail-queue-fqm-suffix)
2319 (defun feedmail-dump-message-to-queue (queue-directory what-event)
2320 (feedmail-say-debug ">in-> feedmail-dump-message-to-queue %s %s" queue-directory what-event)
2321 (or (file-accessible-directory-p queue-directory)
2322 ;; progn to get nil result no matter what
2323 (progn (make-directory queue-directory t) nil)
2324 (file-accessible-directory-p queue-directory)
2325 (error "FQM: Message not queued; trouble with directory %s" queue-directory))
2326 (let ((filename)
2327 (is-fqm)
2328 (is-in-this-dir)
2329 (previous-buffer-file-name buffer-file-name))
2330 (if buffer-file-name
2331 (progn
2332 (setq is-fqm (feedmail-fqm-p buffer-file-name))
2333 (setq is-in-this-dir (string-equal
2334 (directory-file-name
2335 (expand-file-name queue-directory))
2336 (directory-file-name (expand-file-name (file-name-directory buffer-file-name)))))))
2337 ;; if visiting a queued message, just save
2338 (if (and is-fqm is-in-this-dir)
2339 (setq filename buffer-file-name)
2340 (setq filename (feedmail-create-queue-filename queue-directory)))
2341 ;; make binary file on DOS/Windows 95/Windows NT, etc
2342 (let ((coding-system-for-write
2343 (if feedmail-force-binary-write
2344 'no-conversion
2345 coding-system-for-write)))
2346 (write-file filename))
2347 ;; convenient for moving from draft to q, for example
2348 (if (and previous-buffer-file-name (or (not is-fqm) (not is-in-this-dir))
2349 (let (d b s)
2350 (setq b (file-name-nondirectory previous-buffer-file-name))
2351 (setq d (file-name-directory previous-buffer-file-name))
2352 (setq s (substring d (1- (length d))))
2353 (setq d (substring d 0 (1- (length d))))
2354 (setq d (file-name-nondirectory d))
2355 (y-or-n-p (format "FQM: Was previously %s%s%s; delete that? "
2356 d s b))))
2357 (delete-file previous-buffer-file-name))
2358 (if feedmail-nuke-buffer-after-queue
2359 (let ((a-s-file-name buffer-auto-save-file-name))
2360 ;; be aggressive in nuking auto-save files
2361 (and (kill-buffer (current-buffer))
2362 delete-auto-save-files
2363 (file-exists-p a-s-file-name)
2364 (delete-file a-s-file-name))))
2365 (feedmail-say-chatter "Queued in %s" filename)
2366 (if feedmail-queue-chatty
2367 (progn
2368 (feedmail-queue-reminder what-event)
2369 (sit-for feedmail-queue-chatty-sit-for)))))
2372 ;; from a similar function in mail-utils.el
2373 (defun feedmail-rfc822-time-zone (time)
2374 (feedmail-say-debug ">in-> feedmail-rfc822-time-zone %s" time)
2375 (let* ((sec (or (car (current-time-zone time)) 0))
2376 (absmin (/ (abs sec) 60)))
2377 (format "%c%02d%02d" (if (< sec 0) ?- ?+) (/ absmin 60) (% absmin 60))))
2379 (defun feedmail-rfc822-date (arg-time)
2380 (feedmail-say-debug ">in-> feedmail-rfc822-date %s" arg-time)
2381 (let ((time (if arg-time arg-time (current-time)))
2382 (system-time-locale "C"))
2383 (concat
2384 (format-time-string "%a, %e %b %Y %T " time)
2385 (feedmail-rfc822-time-zone time)
2388 (defun feedmail-send-it-immediately-wrapper ()
2389 "Wrapper to catch skip-me-i"
2390 (if (eq 'skip-me-i (catch 'skip-me-i (feedmail-send-it-immediately)))
2391 (error "FQM: Sending...abandoned!")))
2393 (declare-function expand-mail-aliases "mailalias" (beg end &optional exclude))
2395 (defun feedmail-send-it-immediately ()
2396 "Handle immediate sending, including during a queue run."
2397 (feedmail-say-debug ">in-> feedmail-send-it-immediately")
2398 (let ((feedmail-error-buffer
2399 (get-buffer-create " *FQM Outgoing Email Errors*"))
2400 (feedmail-prepped-text-buffer
2401 (get-buffer-create " *FQM Outgoing Email Text*"))
2402 (feedmail-raw-text-buffer (current-buffer))
2403 (feedmail-address-list)
2404 (eoh-marker)
2405 (bcc-holder)
2406 (resent-bcc-holder)
2407 (a-re-rtcb "^Resent-\\(To\\|Cc\\|Bcc\\):")
2408 (a-re-rtc "^Resent-\\(To\\|Cc\\):")
2409 (a-re-rb "^Resent-Bcc:")
2410 (a-re-dtcb "^\\(To\\|Cc\\|Bcc\\):")
2411 (a-re-dtc "^\\(To\\|Cc\\):")
2412 (a-re-db "^Bcc:")
2413 ;; To get a temporary changeable copy.
2414 (mail-header-separator mail-header-separator)
2416 (unwind-protect
2417 (save-current-buffer
2418 (set-buffer feedmail-error-buffer) (erase-buffer)
2419 (set-buffer feedmail-prepped-text-buffer) (erase-buffer)
2421 ;; Jam contents of user-supplied mail buffer into our scratch buffer.
2422 (insert-buffer-substring feedmail-raw-text-buffer)
2424 ;; Require one newline at the end.
2425 (goto-char (point-max))
2426 (or (= (preceding-char) ?\n) (insert ?\n))
2428 (let ((case-fold-search nil))
2429 ;; Change header-delimiter to be what mailers expect (empty line).
2430 ;; leaves match data in place or signals error
2431 (feedmail-say-debug "looking for m-h-s \"%s\""
2432 mail-header-separator)
2433 (setq eoh-marker (feedmail-find-eoh))
2434 (feedmail-say-debug "found m-h-s %s" eoh-marker)
2435 (setq mail-header-separator "")
2436 (replace-match ""))
2437 ;; (replace-match "\\1")) ;; might be empty or "\r"
2439 ;; mail-aliases nil = mail-abbrevs.el
2440 (feedmail-say-debug "expanding mail aliases")
2441 (if (or feedmail-force-expand-mail-aliases
2442 (and (fboundp 'expand-mail-aliases) mail-aliases))
2443 (expand-mail-aliases (point-min) eoh-marker))
2445 ;; Make it pretty.
2446 (if feedmail-fill-to-cc (feedmail-fill-to-cc-function eoh-marker))
2447 ;; Ignore any blank lines in the header.
2448 (goto-char (point-min))
2449 (while (and (re-search-forward "\n\n\n*" eoh-marker t)
2450 (< (point) eoh-marker))
2451 (replace-match "\n"))
2453 (let ((case-fold-search t) (addr-regexp))
2454 (goto-char (point-min))
2455 ;; There are some RFC-822 combinations/cases missed here,
2456 ;; but probably good enough and what users expect.
2458 ;; Use resent-* stuff only if there is at least one non-empty one.
2459 (setq feedmail-is-a-resend
2460 (re-search-forward
2461 ;; Header name, followed by optional whitespace, followed by
2462 ;; non-whitespace, followed by anything, followed by
2463 ;; newline; the idea is empty Resent-* headers are ignored.
2464 "^\\(Resent-To:\\|Resent-Cc:\\|Resent-Bcc:\\)\\s-*\\S-+.*$"
2465 eoh-marker t))
2466 ;; If we say so, gather the Bcc stuff before the main course.
2467 (when (eq feedmail-deduce-bcc-where 'first)
2468 (setq addr-regexp (if feedmail-is-a-resend a-re-rb a-re-db))
2469 (setq feedmail-address-list
2470 (feedmail-deduce-address-list
2471 feedmail-prepped-text-buffer (point-min) eoh-marker
2472 addr-regexp feedmail-address-list)))
2473 ;; The main course.
2474 (setq addr-regexp
2475 (if (memq feedmail-deduce-bcc-where '(first last))
2476 ;; Handled by first or last cases, so don't get
2477 ;; Bcc stuff.
2478 (if feedmail-is-a-resend a-re-rtc a-re-dtc)
2479 ;; Not handled by first or last cases, so also get
2480 ;; Bcc stuff.
2481 (if feedmail-is-a-resend a-re-rtcb a-re-dtcb)))
2482 (setq feedmail-address-list
2483 (feedmail-deduce-address-list
2484 feedmail-prepped-text-buffer (point-min) eoh-marker
2485 addr-regexp feedmail-address-list))
2486 ;; If we say so, gather the Bcc stuff after the main course.
2487 (when (eq feedmail-deduce-bcc-where 'last)
2488 (setq addr-regexp (if feedmail-is-a-resend a-re-rb a-re-db))
2489 (setq feedmail-address-list
2490 (feedmail-deduce-address-list
2491 feedmail-prepped-text-buffer (point-min) eoh-marker
2492 addr-regexp feedmail-address-list)))
2493 (if (not feedmail-address-list)
2494 (error "FQM: Sending...abandoned, no addressees"))
2495 ;; Not needed, but meets user expectations.
2496 (setq feedmail-address-list (nreverse feedmail-address-list))
2497 ;; Find and handle any Bcc fields.
2498 (setq bcc-holder
2499 (feedmail-accume-n-nuke-header eoh-marker "^Bcc:"))
2500 (setq resent-bcc-holder
2501 (feedmail-accume-n-nuke-header eoh-marker "^Resent-Bcc:"))
2502 (when (and bcc-holder (not feedmail-nuke-bcc))
2503 (goto-char (point-min))
2504 (insert bcc-holder))
2505 (when (and resent-bcc-holder (not feedmail-nuke-resent-bcc))
2506 (goto-char (point-min))
2507 (insert resent-bcc-holder))
2508 (goto-char (point-min))
2510 ;; fiddle about, fiddle about, fiddle about....
2511 (feedmail-fiddle-from)
2512 (feedmail-fiddle-sender)
2513 (feedmail-fiddle-x-mailer)
2514 (feedmail-fiddle-message-id
2515 (or feedmail-queue-runner-is-active
2516 (buffer-file-name feedmail-raw-text-buffer)))
2517 (feedmail-fiddle-date
2518 (or feedmail-queue-runner-is-active
2519 (buffer-file-name feedmail-raw-text-buffer)))
2520 (feedmail-fiddle-list-of-fiddle-plexes
2521 feedmail-fiddle-plex-user-list)
2523 ;; don't send out a blank headers of various sorts
2524 ;; (this loses on continued line with a blank first line)
2525 (goto-char (point-min))
2526 (and feedmail-nuke-empty-headers ; hey, who's an empty-header?
2527 (while (re-search-forward "^[A-Za-z0-9-]+:[ \t]*\n"
2528 eoh-marker t)
2529 (replace-match ""))))
2531 (feedmail-say-debug "last chance hook: %s" feedmail-last-chance-hook)
2532 (run-hooks 'feedmail-last-chance-hook)
2534 (save-window-excursion
2535 (let ((fcc (feedmail-accume-n-nuke-header eoh-marker "^Fcc:"))
2536 (also-file)
2537 (confirm (cond
2538 ((eq feedmail-confirm-outgoing 'immediate)
2539 (not feedmail-queue-runner-is-active))
2540 ((eq feedmail-confirm-outgoing 'queued)
2541 feedmail-queue-runner-is-active)
2542 (t feedmail-confirm-outgoing)))
2543 (fullframe (cond
2544 ((eq feedmail-display-full-frame 'immediate)
2545 (not feedmail-queue-runner-is-active))
2546 ((eq feedmail-display-full-frame 'queued)
2547 feedmail-queue-runner-is-active)
2548 (t feedmail-display-full-frame))))
2549 (if fullframe
2550 (progn
2551 (switch-to-buffer feedmail-prepped-text-buffer t)
2552 (delete-other-windows)))
2553 (if (or (not confirm)
2554 (feedmail-one-last-look feedmail-prepped-text-buffer))
2555 (let ((user-mail-address
2556 (feedmail-envelope-deducer eoh-marker)))
2557 (feedmail-say-debug "give it to buffer-eater")
2558 (feedmail-give-it-to-buffer-eater)
2559 (feedmail-say-debug "gave it to buffer-eater")
2560 (if (and (not feedmail-queue-runner-is-active)
2561 (setq also-file
2562 (buffer-file-name feedmail-raw-text-buffer)))
2563 (progn
2564 ;; If a file but not running the queue,
2565 ;; offer to delete it
2566 (setq also-file (expand-file-name also-file))
2567 (when (or feedmail-queue-auto-file-nuke
2568 (y-or-n-p
2569 (format "FQM: Delete message file %s? "
2570 also-file)))
2571 ;; If we delete the affiliated file, get rid
2572 ;; of the file name association and make sure we
2573 ;; don't annoy people with a prompt on exit.
2574 (delete-file also-file)
2575 (with-current-buffer feedmail-raw-text-buffer
2576 (setq buffer-offer-save nil)
2577 (setq buffer-file-name nil)))))
2578 (goto-char (point-min))
2579 ;; Re-insert and handle any Fcc fields (and, optionally,
2580 ;; any Bcc).
2581 (when fcc
2582 (let ((coding-system-for-write
2583 (if (and (memq system-type '(ms-dos windows-nt))
2584 feedmail-force-binary-write)
2585 'no-conversion
2586 coding-system-for-write)))
2587 (unwind-protect
2588 (progn
2589 (insert fcc)
2590 (unless feedmail-nuke-bcc-in-fcc
2591 (if bcc-holder (insert bcc-holder))
2592 (if resent-bcc-holder
2593 (insert resent-bcc-holder)))
2595 (run-hooks 'feedmail-before-fcc-hook)
2597 (when feedmail-nuke-body-in-fcc
2598 (goto-char eoh-marker)
2599 (if (natnump feedmail-nuke-body-in-fcc)
2600 (forward-line feedmail-nuke-body-in-fcc))
2601 (delete-region (point) (point-max)))
2602 (mail-do-fcc eoh-marker))))))
2603 ;; User bailed out of one-last-look.
2604 (if feedmail-queue-runner-is-active
2605 (throw 'skip-me-q 'skip-me-q)
2606 (throw 'skip-me-i 'skip-me-i))
2607 )))) ; unwind-protect body (save-excursion)
2609 ;; unwind-protect cleanup forms.
2610 (kill-buffer feedmail-prepped-text-buffer)
2611 (set-buffer feedmail-error-buffer)
2612 (if (zerop (buffer-size)) (kill-buffer feedmail-error-buffer)
2613 (display-buffer feedmail-error-buffer)
2614 ;; Read fast ... the meter is running.
2615 (if feedmail-queue-runner-is-active
2616 (progn
2617 (ding t)
2618 (feedmail-say-chatter "Sending...failed")))
2619 (error "FQM: Sending...failed"))
2620 (set-buffer feedmail-raw-text-buffer))
2621 ) ; let
2622 (when (and feedmail-queue-chatty (not feedmail-queue-runner-is-active))
2623 (feedmail-queue-reminder 'after-immediate)
2624 (sit-for feedmail-queue-chatty-sit-for)))
2627 (defun feedmail-fiddle-header (name value &optional action folding)
2628 "Internal feedmail function for jamming fields into message header.
2629 NAME, VALUE, ACTION, and FOLDING are the four elements of a
2630 fiddle-plex, as described in the documentation for the variable
2631 `feedmail-fiddle-plex-blurb'."
2632 (feedmail-say-debug ">in-> feedmail-fiddle-header %s %s %s %s"
2633 name value action folding)
2634 (let ((case-fold-search t)
2635 (header-colon (concat (regexp-quote name) ":"))
2636 header-regexp eoh-marker has-like ag-like val-like that-point)
2637 (setq header-regexp (concat "^" header-colon))
2638 (setq eoh-marker (feedmail-find-eoh))
2639 (goto-char (point-min))
2640 (setq has-like (re-search-forward header-regexp eoh-marker t))
2642 (if (not action) (setq action 'supplement))
2643 (cond
2644 ((eq action 'supplement)
2645 ;; trim leading/trailing whitespace
2646 (if (string-match "\\`[ \t\n]+" value)
2647 (setq value (substring value (match-end 0))))
2648 (if (string-match "[ \t\n]+\\'" value)
2649 (setq value (substring value 0 (match-beginning 0))))
2650 (if (> (length value) 0)
2651 (progn
2652 (if feedmail-fiddle-headers-upwardly
2653 (goto-char (point-min))
2654 (goto-char eoh-marker))
2655 (setq that-point (point))
2656 (insert name ": " value "\n")
2657 (if folding (feedmail-fill-this-one that-point (point))))))
2659 ((eq action 'replace)
2660 (if has-like (feedmail-accume-n-nuke-header eoh-marker header-regexp))
2661 (feedmail-fiddle-header name value 'supplement folding))
2663 ((eq action 'create)
2664 (if (not has-like) (feedmail-fiddle-header name value 'supplement folding)))
2666 ((eq action 'combine)
2667 (setq val-like (nth 1 value))
2668 (setq ag-like (or (feedmail-accume-n-nuke-header eoh-marker header-regexp) ""))
2669 ;; get rid of initial header name from first instance (front of string)
2670 (if (string-match (concat header-regexp "[ \t\n]+") ag-like)
2671 (setq ag-like (replace-match "" t t ag-like)))
2672 ;; get rid of embedded header names from subsequent instances
2673 (while (string-match (concat "\n" header-colon "[ \t\n]+") ag-like)
2674 (setq ag-like (replace-match "\n\t" t t ag-like)))
2675 ;; trim leading/trailing whitespace
2676 (if (string-match "\\`[ \t\n]+" ag-like)
2677 (setq ag-like (substring ag-like (match-end 0))))
2678 (if (string-match "[ \t\n]+\\'" ag-like)
2679 (setq ag-like (substring ag-like 0 (match-beginning 0))))
2680 ;; if ag-like is not nil and not an empty string, transform it via a function
2681 ;; call or format operation
2682 (if (> (length ag-like) 0)
2683 (setq ag-like
2684 (cond
2685 ((and (symbolp val-like) (fboundp val-like))
2686 (funcall val-like name ag-like))
2687 ((stringp val-like)
2688 (format val-like ag-like))
2689 (t nil))))
2690 (feedmail-fiddle-header name (concat (nth 0 value) ag-like (nth 2 value)) 'supplement folding)))
2693 (defun feedmail-give-it-to-buffer-eater ()
2694 (feedmail-say-debug ">in-> feedmail-give-it-to-buffer-eater")
2695 (save-excursion
2696 (if feedmail-enable-spray
2697 (mapcar
2698 (lambda (feedmail-spray-this-address)
2699 (let ((spray-buffer (get-buffer-create " *FQM Outgoing Email Spray*")))
2700 (with-current-buffer spray-buffer
2701 (erase-buffer)
2702 ;; not life's most efficient methodology, but spraying isn't
2703 ;; an every-5-minutes event either
2704 (insert-buffer-substring feedmail-prepped-text-buffer)
2705 ;; There's a good case to me made that each separate
2706 ;; transmission of a message in the spray should
2707 ;; have a distinct Message-Id:. There is also a less
2708 ;; compelling argument in the other direction.
2709 ;; I think they technically should have distinct
2710 ;; Message-Id:s, but I doubt that anyone cares,
2711 ;; practically. If someone complains about it, I'll
2712 ;; add it.
2713 (feedmail-fiddle-list-of-spray-fiddle-plexes feedmail-spray-address-fiddle-plex-list)
2714 ;; this (let ) is just in case some buffer eater
2715 ;; is cheating and using the global variable name instead
2716 ;; of its argument to find the buffer
2717 (let ((feedmail-prepped-text-buffer spray-buffer))
2718 (funcall feedmail-buffer-eating-function
2719 feedmail-prepped-text-buffer
2720 feedmail-error-buffer
2721 (list feedmail-spray-this-address))))
2722 (kill-buffer spray-buffer)
2724 feedmail-address-list)
2725 (feedmail-say-debug "calling buffer-eater %s"
2726 feedmail-buffer-eating-function)
2727 (funcall feedmail-buffer-eating-function
2728 feedmail-prepped-text-buffer
2729 feedmail-error-buffer
2730 feedmail-address-list))))
2733 (defun feedmail-envelope-deducer (eoh-marker)
2734 "If `feedmail-deduce-envelope-from' is false, simply return `user-mail-address'.
2735 Else, look for Sender: or From: (or Resent-*) and
2736 return that value."
2737 (feedmail-say-debug ">in-> feedmail-envelope-deducer %s" eoh-marker)
2738 (if (not feedmail-deduce-envelope-from)
2739 user-mail-address
2740 (let ((from-list))
2741 (setq from-list
2742 (feedmail-deduce-address-list
2743 (current-buffer) (point-min) eoh-marker (if feedmail-is-a-resend "^Resent-Sender:" "^Sender:")
2744 from-list))
2745 (if (not from-list)
2746 (setq from-list
2747 (feedmail-deduce-address-list
2748 (current-buffer) (point-min) eoh-marker (if feedmail-is-a-resend "^Resent-From:" "^From:")
2749 from-list)))
2750 (if (and from-list (car from-list)) (car from-list) user-mail-address))))
2753 (defun feedmail-fiddle-from ()
2754 "Fiddle From:."
2755 (feedmail-say-debug ">in-> feedmail-fiddle-from")
2756 ;; default is to fall off the end of the list and do nothing
2757 (cond
2758 ;; nil means do nothing
2759 ((eq nil feedmail-from-line) nil)
2760 ;; t is the same a using the default computation, so compute it and recurse
2761 ;; user-full-name suggested by kpc@ptolemy.arc.nasa.gov (=Kimball Collins)
2762 ;; improvement using user-mail-address suggested by
2763 ;; gray@austin.apc.slb.com (Douglas Gray Stephens)
2764 ;; improvement using mail-host-address suggested by "Jason Eisner" <jason@cs.jhu.edu>
2765 ;; ((this situation really is hopeless, though)
2766 ((eq t feedmail-from-line)
2767 (let ((feedmail-from-line
2768 (let ((at-stuff
2769 (if user-mail-address user-mail-address
2770 (concat (user-login-name) "@"
2771 (or mail-host-address (system-name))))))
2772 (cond
2773 ((eq mail-from-style nil) at-stuff)
2774 ((eq mail-from-style 'parens) (concat at-stuff " (" (user-full-name) ")"))
2775 ((eq mail-from-style 'angles) (concat "\"" (user-full-name) "\" <" at-stuff ">"))
2776 ))))
2777 (feedmail-fiddle-from)))
2779 ;; if it's a string, simply make a fiddle-plex out of it and recurse
2780 ((stringp feedmail-from-line)
2781 (let ((feedmail-from-line (list "ignored" feedmail-from-line 'create)))
2782 (feedmail-fiddle-from)))
2784 ;; if it's a function, call it and recurse with the resulting value
2785 ((and (symbolp feedmail-from-line) (fboundp feedmail-from-line))
2786 (let ((feedmail-from-line (funcall feedmail-from-line)))
2787 (feedmail-fiddle-from)))
2789 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
2790 ((listp feedmail-from-line)
2791 (feedmail-fiddle-header
2792 (if feedmail-is-a-resend "Resent-From" "From")
2793 (nth 1 feedmail-from-line) ; value
2794 (nth 2 feedmail-from-line) ; action
2795 (nth 3 feedmail-from-line))))) ; folding
2798 (defun feedmail-fiddle-sender ()
2799 "Fiddle Sender:."
2800 (feedmail-say-debug ">in-> feedmail-fiddle-sender")
2801 ;; default is to fall off the end of the list and do nothing
2802 (cond
2803 ;; nil means do nothing
2804 ((eq nil feedmail-sender-line) nil)
2805 ;; t is not allowed, but handled it just to avoid bugs later
2806 ((eq t feedmail-sender-line) nil)
2808 ;; if it's a string, simply make a fiddle-plex out of it and recurse
2809 ((stringp feedmail-sender-line)
2810 (let ((feedmail-sender-line (list "ignored" feedmail-sender-line 'create)))
2811 (feedmail-fiddle-sender)))
2813 ;; if it's a function, call it and recurse with the resulting value
2814 ((and (symbolp feedmail-sender-line) (fboundp feedmail-sender-line))
2815 (let ((feedmail-sender-line (funcall feedmail-sender-line)))
2816 (feedmail-fiddle-sender)))
2818 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
2819 ((listp feedmail-sender-line)
2820 (feedmail-fiddle-header
2821 (if feedmail-is-a-resend "Resent-Sender" "Sender")
2822 (nth 1 feedmail-sender-line) ; value
2823 (nth 2 feedmail-sender-line) ; action
2824 (nth 3 feedmail-sender-line))))) ; folding
2827 (defun feedmail-default-date-generator (maybe-file)
2828 "Default function for generating Date: header contents."
2829 (feedmail-say-debug ">in-> feedmail-default-date-generator")
2830 (when maybe-file
2831 (feedmail-say-debug (concat "4 cre " (feedmail-rfc822-date (nth 4 (file-attributes maybe-file)))))
2832 (feedmail-say-debug (concat "5 mod " (feedmail-rfc822-date (nth 5 (file-attributes maybe-file)))))
2833 (feedmail-say-debug (concat "6 sta " (feedmail-rfc822-date (nth 6 (file-attributes maybe-file))))))
2834 (let ((date-time))
2835 (if (and (not feedmail-queue-use-send-time-for-date) maybe-file)
2836 (setq date-time (nth 5 (file-attributes maybe-file))))
2837 (feedmail-rfc822-date date-time))
2841 (defun feedmail-fiddle-date (maybe-file)
2842 "Fiddle Date:. See documentation of `feedmail-date-generator'."
2843 (feedmail-say-debug ">in-> feedmail-fiddle-date")
2844 ;; default is to fall off the end of the list and do nothing
2845 (cond
2846 ;; nil means do nothing
2847 ((eq nil feedmail-date-generator) nil)
2848 ;; t is the same a using the function feedmail-default-date-generator, so let it and recurse
2849 ((eq t feedmail-date-generator)
2850 (let ((feedmail-date-generator (feedmail-default-date-generator maybe-file)))
2851 (feedmail-fiddle-date maybe-file)))
2853 ;; if it's a string, simply make a fiddle-plex out of it and recurse
2854 ((stringp feedmail-date-generator)
2855 (let ((feedmail-date-generator (list "ignored" feedmail-date-generator 'create)))
2856 (feedmail-fiddle-date maybe-file)))
2858 ;; if it's a function, call it and recurse with the resulting value
2859 ((and (symbolp feedmail-date-generator) (fboundp feedmail-date-generator))
2860 (let ((feedmail-date-generator (funcall feedmail-date-generator maybe-file)))
2861 (feedmail-fiddle-date maybe-file)))
2863 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
2864 ((listp feedmail-date-generator)
2865 (feedmail-fiddle-header
2866 (if feedmail-is-a-resend "Resent-Date" "Date")
2867 (nth 1 feedmail-date-generator) ; value
2868 (nth 2 feedmail-date-generator) ; action
2869 (nth 3 feedmail-date-generator))))) ; folding
2872 (defun feedmail-default-message-id-generator (maybe-file)
2873 "Default function for generating Message-Id: header contents.
2874 Based on a date and a sort of random number for tie breaking. Unless
2875 `feedmail-message-id-suffix' is defined, uses `user-mail-address', so be
2876 sure it's set. If both are nil, creates a quasi-random suffix that is
2877 probably not appropriate for you."
2878 (feedmail-say-debug ">in-> feedmail-default-message-id-generator %s"
2879 maybe-file)
2880 (let ((date-time)
2881 (system-time-locale "C")
2882 (end-stuff (if feedmail-message-id-suffix feedmail-message-id-suffix user-mail-address)))
2883 (if (not end-stuff) (setq end-stuff (format "%d.example.com" (random))))
2884 (if (string-match "^\\(.*\\)@" end-stuff)
2885 (setq end-stuff
2886 (concat (if (equal (match-beginning 1) (match-end 1)) "" "-") end-stuff))
2887 (setq end-stuff (concat "@" end-stuff)))
2888 (if (and (not feedmail-queue-use-send-time-for-message-id) maybe-file)
2889 (setq date-time (nth 5 (file-attributes maybe-file))))
2890 (format "<%d-%s%s%s>"
2891 (mod (random) 10000)
2892 (format-time-string "%a%d%b%Y%H%M%S" date-time)
2893 (feedmail-rfc822-time-zone date-time)
2894 end-stuff))
2897 (defun feedmail-fiddle-message-id (maybe-file)
2898 "Fiddle Message-Id:. See documentation of `feedmail-message-id-generator'."
2899 (feedmail-say-debug ">in-> feedmail-fiddle-message-id %s" maybe-file)
2900 ;; default is to fall off the end of the list and do nothing
2901 (cond
2902 ;; nil means do nothing
2903 ((eq nil feedmail-message-id-generator) nil)
2904 ;; t is the same a using the function feedmail-default-message-id-generator, so let it and recurse
2905 ((eq t feedmail-message-id-generator)
2906 (let ((feedmail-message-id-generator (feedmail-default-message-id-generator maybe-file)))
2907 (feedmail-fiddle-message-id maybe-file)))
2909 ;; if it's a string, simply make a fiddle-plex out of it and recurse
2910 ((stringp feedmail-message-id-generator)
2911 (let ((feedmail-message-id-generator (list "ignored" feedmail-message-id-generator 'create)))
2912 (feedmail-fiddle-message-id maybe-file)))
2914 ;; if it's a function, call it and recurse with the resulting value
2915 ((and (symbolp feedmail-message-id-generator) (fboundp feedmail-message-id-generator))
2916 (let ((feedmail-message-id-generator (funcall feedmail-message-id-generator maybe-file)))
2917 (feedmail-fiddle-message-id maybe-file)))
2919 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
2920 ((listp feedmail-message-id-generator)
2921 (feedmail-fiddle-header
2922 (if feedmail-is-a-resend "Resent-Message-Id" "Message-Id")
2923 (nth 1 feedmail-message-id-generator) ; value
2924 (nth 2 feedmail-message-id-generator) ; action
2925 (nth 3 feedmail-message-id-generator))))) ; folding
2928 (defun feedmail-default-x-mailer-generator ()
2929 "Default function for generating X-Mailer: header contents."
2930 (concat
2931 (let ((case-fold-search t)) (if (string-match "emacs" emacs-version) "" "emacs "))
2932 emacs-version " (via feedmail " feedmail-patch-level
2933 (if feedmail-queue-runner-is-active " Q" " I")
2934 (if feedmail-enable-spray "S" "")
2935 (if feedmail-x-mailer-line-user-appendage ") " ")")
2936 feedmail-x-mailer-line-user-appendage))
2939 (defun feedmail-fiddle-x-mailer ()
2940 "Fiddle X-Mailer:. See documentation of `feedmail-x-mailer-line'."
2941 (feedmail-say-debug ">in-> feedmail-fiddle-x-mailer")
2942 ;; default is to fall off the end of the list and do nothing
2943 (cond
2944 ;; nil means do nothing
2945 ((eq nil feedmail-x-mailer-line) nil)
2946 ;; t is the same a using the function feedmail-default-x-mailer-generator, so let it and recurse
2947 ((eq t feedmail-x-mailer-line)
2948 (let ((feedmail-x-mailer-line (feedmail-default-x-mailer-generator)))
2949 (feedmail-fiddle-x-mailer)))
2951 ;; if it's a string, simply make a fiddle-plex out of it and recurse
2952 ((stringp feedmail-x-mailer-line)
2953 (let ((feedmail-x-mailer-line (list "ignored" (list feedmail-x-mailer-line ";\n\t%s") 'combine)))
2954 (feedmail-fiddle-x-mailer)))
2956 ;; if it's a function, call it and recurse with the resulting value
2957 ((and (symbolp feedmail-x-mailer-line) (fboundp feedmail-x-mailer-line))
2958 (let ((feedmail-x-mailer-line (funcall feedmail-x-mailer-line)))
2959 (feedmail-fiddle-x-mailer)))
2961 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
2962 ((listp feedmail-x-mailer-line)
2963 (feedmail-fiddle-header
2964 (if feedmail-is-a-resend "X-Resent-Mailer" "X-Mailer")
2965 (nth 1 feedmail-x-mailer-line) ; value
2966 (nth 2 feedmail-x-mailer-line) ; action
2967 (nth 3 feedmail-x-mailer-line))))) ; folding
2970 (defun feedmail-fiddle-spray-address (addy-plex)
2971 "Fiddle header for single spray address. Uses `feedmail-spray-this-address'."
2972 (feedmail-say-debug ">in-> feedmail-fiddle-spray-address %s" addy-plex)
2973 ;; default is to fall off the end of the list and do nothing
2974 (cond
2975 ;; nil means do nothing
2976 ((eq nil addy-plex) nil)
2977 ;; t means the same as using "To:" and unembellished addy
2978 ((eq t addy-plex)
2979 (let ((addy-plex (list "To" feedmail-spray-this-address)))
2980 (feedmail-fiddle-spray-address addy-plex)))
2982 ;; if it's a string, simply make a fiddle-plex out of it and recurse, assuming
2983 ;; the string names a header field (e.g., "To")
2984 ((stringp addy-plex)
2985 (let ((addy-plex (list addy-plex feedmail-spray-this-address)))
2986 (feedmail-fiddle-spray-address addy-plex)))
2988 ;; if it's a function, call it and recurse with the resulting value
2989 ((and (symbolp addy-plex) (fboundp addy-plex))
2990 (let ((addy-plex (funcall addy-plex)))
2991 (feedmail-fiddle-spray-address addy-plex)))
2993 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
2994 ((listp addy-plex)
2995 (feedmail-fiddle-header
2996 (nth 0 addy-plex) ; name
2997 (nth 1 addy-plex) ; value
2998 (nth 2 addy-plex) ; action
2999 (nth 3 addy-plex))))) ; folding
3002 (defun feedmail-fiddle-list-of-spray-fiddle-plexes (list-of-fiddle-plexes)
3003 "Fiddling based on a list of fiddle-plexes for spraying."
3004 (feedmail-say-debug ">in-> feedmail-fiddle-list-of-spray-fiddle-plexes")
3005 ;; default is to fall off the end of the list and do nothing
3006 (let ((lofp list-of-fiddle-plexes) fp)
3007 (if (listp lofp)
3008 (while lofp
3009 (setq fp (car lofp))
3010 (setq lofp (cdr lofp))
3011 (feedmail-fiddle-spray-address fp))
3012 (feedmail-fiddle-spray-address lofp))))
3015 (defun feedmail-fiddle-list-of-fiddle-plexes (list-of-fiddle-plexes)
3016 "Fiddling based on a list of fiddle-plexes. Values t, nil, and string are pointless."
3017 (feedmail-say-debug ">in-> feedmail-fiddle-list-of-fiddle-plexes")
3018 ;; default is to fall off the end of the list and do nothing
3019 (let ((lofp list-of-fiddle-plexes) fp)
3020 (while lofp
3021 (setq fp (car lofp))
3022 (setq lofp (cdr lofp))
3023 (cond
3025 ;; if it's a function, call it and recurse with the resulting value
3026 ((and (symbolp fp) (fboundp fp))
3027 (let ((lofp (list (funcall fp)))) (feedmail-fiddle-list-of-fiddle-plexes lofp)))
3029 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
3030 ((listp fp)
3031 (feedmail-fiddle-header
3032 (nth 0 fp)
3033 (nth 1 fp) ; value
3034 (nth 2 fp) ; action
3035 (nth 3 fp))))))) ; folding
3038 (defun feedmail-accume-n-nuke-header (header-end header-regexp)
3039 "Delete headers matching a regexp and their continuation lines.
3040 There may be multiple such lines, and each may have arbitrarily
3041 many continuation lines. Return an accumulation of the deleted
3042 headers, including the intervening newlines."
3043 (feedmail-say-debug ">in-> feedmail-accume-n-nuke-header %s %s"
3044 header-end header-regexp)
3045 (let ((case-fold-search t) (dropout))
3046 (save-excursion
3047 (goto-char (point-min))
3048 ;; iterate over all matching lines
3049 (while (re-search-forward header-regexp header-end t)
3050 (forward-line 1)
3051 (setq dropout (concat dropout (buffer-substring-no-properties (match-beginning 0) (point))))
3052 (delete-region (match-beginning 0) (point))
3053 ;; get rid of any continuation lines
3054 (while (and (looking-at "^[ \t].*\n") (< (point) header-end))
3055 (forward-line 1)
3056 (setq dropout (concat dropout (buffer-substring-no-properties (match-beginning 0) (point))))
3057 (replace-match ""))))
3058 (identity dropout)))
3060 (defun feedmail-fill-to-cc-function (header-end)
3061 "Smart filling of address headers (don't be fooled by the name).
3062 The filling tries to avoid splitting lines except at commas. This
3063 avoids, in particular, splitting within parenthesized comments in
3064 addresses. Headers filled include From:, Reply-To:, To:, Cc:, Bcc:,
3065 Resent-To:, Resent-Cc:, and Resent-Bcc:."
3066 (feedmail-say-debug ">in-> feedmail-fill-to-cc-function")
3067 (let ((case-fold-search t)
3068 this-line
3069 this-line-end)
3070 (save-excursion
3071 (goto-char (point-min))
3072 ;; iterate over all To:/Cc:, etc, lines
3073 (while
3074 (re-search-forward
3075 "^\\(From:\\|Reply-To:\\|To:\\|Cc:\\|Bcc:\\|Resent-To:\\|Resent-Cc:\\|Resent-Bcc:\\)"
3076 header-end t)
3077 (setq this-line (match-beginning 0))
3078 ;; replace 0 or more leading spaces with a single space
3079 (and (looking-at "[ \t]*") (replace-match " "))
3080 (forward-line 1)
3081 ;; get any continuation lines
3082 (while (and (looking-at "[ \t]+") (< (point) header-end))
3083 (forward-line 1))
3084 (setq this-line-end (point-marker))
3085 (save-excursion (feedmail-fill-this-one this-line this-line-end))
3086 ))))
3089 (defun feedmail-fill-this-one (this-line this-line-end)
3090 "In-place smart filling of the region bounded by the two arguments."
3091 (feedmail-say-debug ">in-> feedmail-fill-this-one")
3092 (let ((fill-prefix "\t")
3093 (fill-column feedmail-fill-to-cc-fill-column))
3094 ;; The general idea is to break only on commas. Collapse
3095 ;; multiple whitespace to a single blank; change
3096 ;; all the blanks to something unprintable; change the
3097 ;; commas to blanks; fill the region; change it back.
3098 (goto-char this-line)
3099 (while (re-search-forward "\\s-+" (1- this-line-end) t)
3100 (replace-match " "))
3102 (subst-char-in-region this-line this-line-end ? 2 t) ; blank->C-b
3103 (subst-char-in-region this-line this-line-end ?, ? t) ; comma->blank
3105 (fill-region-as-paragraph this-line this-line-end)
3107 (subst-char-in-region this-line this-line-end ? ?, t) ; comma<-blank
3108 (subst-char-in-region this-line this-line-end 2 ? t) ; blank<-C-b
3110 ;; look out for missing commas before continuation lines
3111 (goto-char this-line)
3112 (while (re-search-forward "\\([^,]\\)\n\t[ ]*" this-line-end t)
3113 (replace-match "\\1,\n\t"))
3117 (defun feedmail-deduce-address-list (message-buffer header-start header-end addr-regexp address-list)
3118 "Get address list with all comments and other excitement trimmed.
3119 Addresses are collected only from headers whose names match the fourth
3120 argument. Returns a list of strings. Duplicate addresses will have
3121 been weeded out."
3122 (feedmail-say-debug ">in-> feedmail-deduce-address-list %s %s" addr-regexp address-list)
3123 (let ((simple-address)
3124 (address-blob)
3125 (this-line)
3126 (this-line-end))
3127 (unwind-protect
3128 (with-current-buffer (get-buffer-create " *FQM scratch*")
3129 (erase-buffer)
3130 (insert-buffer-substring message-buffer header-start header-end)
3131 (goto-char (point-min))
3132 (let ((case-fold-search t))
3133 (while (re-search-forward addr-regexp (point-max) t)
3134 (replace-match "")
3135 (setq this-line (match-beginning 0))
3136 (forward-line 1)
3137 ;; get any continuation lines
3138 (while (and (looking-at "^[ \t]+") (< (point) (point-max)))
3139 (forward-line 1))
3140 (setq this-line-end (point-marker))
3141 ;; only keep if we don't have it already
3142 (setq address-blob
3143 (mail-strip-quoted-names (buffer-substring-no-properties this-line this-line-end)))
3144 (while (string-match "\\([, \t\n\r]*\\)\\([^, \t\n\r]+\\)" address-blob)
3145 (setq simple-address (substring address-blob (match-beginning 2) (match-end 2)))
3146 (setq address-blob (replace-match "" t t address-blob))
3147 (if (not (member simple-address address-list))
3148 (add-to-list 'address-list simple-address)))
3150 (kill-buffer nil)))
3151 (identity address-list)))
3154 (defun feedmail-one-last-look (feedmail-prepped-text-buffer)
3155 "Offer the user one last chance to give it up."
3156 (feedmail-say-debug ">in-> feedmail-one-last-look")
3157 (save-excursion
3158 (save-window-excursion
3159 (switch-to-buffer feedmail-prepped-text-buffer)
3160 (if (and (fboundp 'y-or-n-p-with-timeout) (numberp feedmail-confirm-outgoing-timeout))
3161 (y-or-n-p-with-timeout
3162 "FQM: Send this email? "
3163 (abs feedmail-confirm-outgoing-timeout)
3164 (> feedmail-confirm-outgoing-timeout 0))
3165 (y-or-n-p "FQM: Send this email? "))
3168 (defun feedmail-fqm-p (might-be)
3169 "Internal; does filename end with FQM suffix?"
3170 (feedmail-say-debug ">in-> feedmail-fqm-p %s" might-be)
3171 (string-match (concat (regexp-quote feedmail-queue-fqm-suffix) "$") might-be))
3173 (defun feedmail-say-debug (format &optional a1 a2 a3 a4 a5 a6 a7 a8 a9)
3174 "Internal; emits debug messages in standard format."
3175 (when feedmail-debug
3176 (funcall 'message (concat "FQM DB: " format) a1 a2 a3 a4 a5 a6 a7 a8 a9)
3177 (and feedmail-debug-sit-for (not (= 0 feedmail-debug-sit-for))
3178 (sit-for feedmail-debug-sit-for))))
3180 (defun feedmail-say-chatter (format &optional a1 a2 a3 a4 a5 a6 a7 a8 a9)
3181 "Internal; emits queue chatter messages in standard format."
3182 (when feedmail-queue-chatty
3183 (funcall 'message (concat "FQM: " format) a1 a2 a3 a4 a5 a6 a7 a8 a9)
3184 (and feedmail-queue-chatty-sit-for (not (= 0 feedmail-queue-chatty-sit-for))
3185 (sit-for feedmail-queue-chatty-sit-for))))
3187 (defun feedmail-find-eoh (&optional noerror)
3188 "Internal; finds the end of message header fields, returns mark just before it"
3189 ;; all this funny business with line endings is to account for CRLF
3190 ;; weirdness that I don't think I'll ever figure out
3191 (feedmail-say-debug ">in-> feedmail-find-eoh %s" noerror)
3192 (let ((mhs mail-header-separator)
3193 (alt-mhs feedmail-queue-alternative-mail-header-separator)
3194 r-mhs r-alt-mhs)
3195 (setq r-mhs (concat "^" (regexp-quote mhs) "$"))
3196 (setq r-alt-mhs (concat "^" (regexp-quote (or alt-mhs "")) "$"))
3197 (save-excursion
3198 (goto-char (point-min))
3199 (if (or (re-search-forward r-mhs nil t)
3200 (and alt-mhs (re-search-forward r-alt-mhs nil t)))
3201 (progn
3202 (beginning-of-line)
3203 (point-marker))
3204 (if noerror
3206 (error "FQM: Can't find message-header-separator or alternate"))))))
3208 (provide 'feedmail)
3210 ;;; feedmail.el ends here