-;;; feedmail.el --- assist other email packages to massage outgoing messages
+;;; feedmail.el --- assist other email packages to massage outgoing messages
;;; A replacement for parts of GNUemacs' sendmail.el (specifically,
;;; it's what handles your outgoing mail after you hit C-c C-c in mail
;;; mode). See below for a list of additional features, including the
;; using, and what versions of other email-related elisp packages you
;; are using. If in doubt about any of that, send the bug report
;; A NOTE TO THOSE WHO WOULD CHANGE THIS CODE... Since it is PD,
;; you're within your rights to do whatever you want. If you do
;; (autoload 'feedmail-buffer-to-smtp "feedmail" nil t)
;; (setq feedmail-buffer-eating-function 'feedmail-buffer-to-smtp)
-;; If you are using the desktop.el library to restore your sessions, you might
+;; If you are using the desktop.el library to restore your sessions, you might
;; like to add the suffix ".fqm" to the list of non-saved things via the variable
;; (add-hook 'message-mail-send-hook 'feedmail-mail-send-hook-splitter)
;; If you use message-mode and you make use of feedmail's queueing
-;; stuff, you might also like to adjust these variables to appropriate
+;; stuff, you might also like to adjust these variables to appropriate
;; values for message-mode:
;; If you are using the "cmail" email package, there is some built-in
;; support for feedmail in recent versions. To enable it, you should:
;; systems with non-classic /bin/[r]mail behavior
;; guard against nil user-mail-address in generating MESSAGE-ID:
;; feedmail-queue-slug-suspect-regexp is now a variable to
-;; accomodate non-ASCII environments (thanks to
+;; accomodate non-ASCII environments (thanks to
;; Makoto.Nakagawa@jp.compaq.com for this suggestion)
;; feedmail-buffer-to-smtp, to parallel feedmail-buffer-to-smtpmail
;; patchlevel 10, 22 April 2001
combining its efforts with any existing X-MAILER: header. If you want
to take the default construct and just add a little blob of your own
at the end, define the variable feedmail-x-mailer-line-user-appendage
-as that blob string. A value of t is equivalent to using the function
+as that blob string. A value of t is equivalent to using the function
If neither nil nor t, it may be a string, a fiddle-plex, or a function
of addressees. If this variable is non-nil, however, feedmail will
repeatedly call the same buffer-eating function. Each time, the list of
addressees will be just one item from the original list. This only affects
-the message envelope addresses and doesn't affect what appears in the
+the message envelope addresses and doesn't affect what appears in the
message headers except as noted.
Spray mode is usually pointless, and if you can't think of a good reason for
-it, you should avoid it since it is inherently less efficient than normal
+it, you should avoid it since it is inherently less efficient than normal
multiple delivery. One reason to use it is to overcome mis-featured mail
transports which betray your trust by revealing BCC: addressees in the
headers of a message. Another use is to do a crude form of mailmerge, for
May be a function, in which case it is called with no arguments and is
expected to return nil, t, a string, another function, or a fiddle-plex.
The result is used recursively. The function may alter the value of the
-variable feedmail-spray-this-address, perhaps to embellish it with a
+variable feedmail-spray-this-address, perhaps to embellish it with a
human name. It would be logical in such a case to return as a value a
string naming a message header like \"TO\" or an appropriately constructed
fiddle-plex. For an example, see feedmail-spray-via-bbdb.
in place of strings which may cause problems in filenames. By default,
only alphanumeric and hyphen characters are kept, and all others are
converted. In non-ASCII environments, it may be more helpful to
-tweak this regular expression to reflect local or personal language
+tweak this regular expression to reflect local or personal language
conventions. Substitutions are done repeatedly until the regular expression
no longer matches to transformed string. Used by function
feedmail-tidy-up-slug and indirectly by feedmail-queue-subject-slug-maker."
(defcustom feedmail-queue-default-file-slug t
"*Indicates what to use for subject-less messages when forming a file name.
-When feedmail queues a message, it creates a unique file name. By default,
+When feedmail queues a message, it creates a unique file name. By default,
the file name is based in part on the subject of the message being queued.
If there is no subject, consult this variable. See documentation for the
Normally, feedmail will notice such files when you send a message in
immediate mode \(i.e., not when you're running the queue\) and will ask if
you want to delete them. Since the answer is usually yes, setting this
-variable to non-nil will tell feedmail to skip the prompt and just delete
+variable to non-nil will tell feedmail to skip the prompt and just delete
the file without bothering you."
"If non-nil, has the value normally expected of 'buffer-file-name'.
You are not intended to set this to something in your configuration. Rather,
you might programmatically set it to something via a hook or function
-advice or whatever. You might like to do this if you are using a mail
+advice or whatever. You might like to do this if you are using a mail
composition program that eventually uses sendmail.el's 'mail-send'
function to process the message. If there is a filename associated
with the message buffer, 'mail-send' will ask you for confirmation.
-There's no trivial way to avoid it. It's unwise to just set the value
+There's no trivial way to avoid it. It's unwise to just set the value
of 'buffer-file-name' to nil because that will defeat feedmail's file
management features. Instead, arrange for this variable to be set to
-the value of 'buffer-file-name' before setting that to nil. An easy way
+the value of 'buffer-file-name' before setting that to nil. An easy way
to do that would be with defadvice on 'mail-send' \(undoing the
assignments in a later advice\).
feedmail will pretend that 'buffer-file-name', if nil, has the value
-assigned of 'feedmail-queue-buffer-file-name' and carry out its normal
+assigned of 'feedmail-queue-buffer-file-name' and carry out its normal
activities. feedmail does not restore the non-nil value of
-'buffer-file-name'. For safe bookkeeping, the user should insure that
+'buffer-file-name'. For safe bookkeeping, the user should insure that
feedmail-queue-buffer-file-name is restored to nil.
Example 'defadvice' for mail-send:
\(defadvice mail-send \(before feedmail-mail-send-before-advice activate\)
\(setq feedmail-queue-buffer-file-name buffer-file-name\)
\(setq buffer-file-name nil\)\)
\(defadvice mail-send \(after feedmail-mail-send-after-advice activate\)
\(setq buffer-file-name feedmail-queue-buffer-file-name\)\)
+ \(setq buffer-file-name feedmail-queue-buffer-file-name\)\)
\(setq feedmail-queue-buffer-file-name nil\)\)
Called for each message read back out of the queue directory with a
single argument, the optional argument used in the call to
feedmail-run-the-queue or feedmail-run-the-queue-no-prompts.
-Interactively, that argument will be the prefix argument.
+Interactively, that argument will be the prefix argument.
Most people want mail-send \(bound to C-c C-s in mail-mode\), but here's
your chance to have something different. The default value is just a
wrapper function which discards the optional argument and calls
(if (fboundp #'user-login-name) (user-login-name) "feedmail")
" ; cat -) | /usr/bin/rmail %s")
'create Insert this one only if no like field exists.
'combine Combine aggregate values of like fields with this one.
- In this case, VALUE has a special form. It is a list
- of three items: VAL-PRE, VAL-LIKE, and VAL-POST.
- VAL-PRE and VAL-POST are strings or nil. VAL-LIKE may
- be either a string or a function \(it may also be nil,
- but there's not much point to that\).
- Values of like header fields are aggregated, leading and
- trailing whitespace is removed, and embedded
- whitespace is left as-is. If there are no like
- fields, or the aggregate value is an empty string,
- VAL-LIKE is not used. Else, if VAL-LIKE is a function,
- it is called with two arguments: NAME and the
- aggregate like values. Else, if VAL-LIKE is a string, it is
- used as a format string where a single \%s will be
- replaced by the aggregate values of like fields.
- VAL-PRE, the results of using VAL-LIKE, and VAL-POST
- are concatenated, and the result, if not nil and not
- an empty string, is used as the new value for the
- field. Although this description sounds a bit
- complicated, the idea is to provide a mechanism for
- combining the old value with a new value in a flexible
- way. For example, if you wanted to add a new value to
- an existing header field by adding a semi-colon and
- then starting the new value on a continuation line,
- you might specify this:
- \(nil \"%s;\\n\\t\" \"This is my new value\"\)
+ In this case, VALUE has a special form. It is a list
+ of three items: VAL-PRE, VAL-LIKE, and VAL-POST.
+ VAL-PRE and VAL-POST are strings or nil. VAL-LIKE may
+ be either a string or a function \(it may also be nil,
+ but there's not much point to that\).
+ Values of like header fields are aggregated, leading and
+ trailing whitespace is removed, and embedded
+ whitespace is left as-is. If there are no like
+ fields, or the aggregate value is an empty string,
+ VAL-LIKE is not used. Else, if VAL-LIKE is a function,
+ it is called with two arguments: NAME and the
+ aggregate like values. Else, if VAL-LIKE is a string, it is
+ used as a format string where a single \%s will be
+ replaced by the aggregate values of like fields.
+ VAL-PRE, the results of using VAL-LIKE, and VAL-POST
+ are concatenated, and the result, if not nil and not
+ an empty string, is used as the new value for the
+ field. Although this description sounds a bit
+ complicated, the idea is to provide a mechanism for
+ combining the old value with a new value in a flexible
+ way. For example, if you wanted to add a new value to
+ an existing header field by adding a semi-colon and
+ then starting the new value on a continuation line,
+ you might specify this:
+ \(nil \"%s;\\n\\t\" \"This is my new value\"\)
FOLDING can be nil, in which case VALUE is used as-is. If FOLDING is
non-nil, feedmail \"smart filling\" is done on VALUE just before
(defun feedmail-vm-mail-mode (&optional arg)
"Make something like a buffer that has been created via vm-mail.
The optional argument is ignored and is just for argument compatibility with
-feedmail-queue-runner-mode-setter. This function is suitable for being
+feedmail-queue-runner-mode-setter. This function is suitable for being
applied to a file after you've just read it from disk: for example, a
feedmail FQM message file from a queue. You could use something like
(defun feedmail-run-the-queue-global-prompt (&optional arg)
"Like feedmail-run-the-queue, but with a global confirmation prompt.
-This is generally most useful if run non-interactively, since you can
+This is generally most useful if run non-interactively, since you can
bail out with an appropriate answer to the global confirmation prompt."
(feedmail-say-debug ">in-> feedmail-run-the-queue-global-prompts")
(setq maybe-file (expand-file-name blobby feedmail-queue-directory))
- ((file-directory-p maybe-file) nil) ; don't care about subdirs
+ ((file-directory-p maybe-file) nil) ; don't care about subdirs
(setq blobby-buffer (generate-new-buffer (concat "FQM " blobby)))
(setq buffer-offer-save nil)
(replace-match "\n" nil t)))
;; ;; work around text-vs-binary wierdness
;; ;; if we don't find the normal M-H-S, try reading the file a different way
(if (not (feedmail-find-eoh t))
+;; (if (not (feedmail-find-eoh t))
;; (let ((file-name-buffer-file-type-alist nil) (default-buffer-file-type nil))
;; (insert-file-contents maybe-file)))
(feedmail-say-chatter "%d sent, %d skipped (%d other files ignored)"
messages-sent messages-skipped q-oth)
(if (pos-visible-in-window-p (point-min) fqm-window)
(defun feedmail-look-at-queue-directory (queue-directory)
"Find out some things about a queue directory.
;; for tidyness, peel off trailing hyphens
(if (string-match "-*$" slug) (setq slug (replace-match "" nil nil slug)))
(defun feedmail-queue-subject-slug-maker (&optional queue-directory)
"Create a name for storing the message in the queue.
(while (and (re-search-forward "\n\n\n*" eoh-marker t)
(let ((case-fold-search t) (addr-regexp))
;; there are some RFC-822 combinations/cases missed here,
;; if we delete the affiliated file, get rid
- ;; of the file name association and make sure we
+ ;; of the file name association and make sure we
;; don't annoy people with a prompt on exit
(progn (if bcc-holder (insert bcc-holder))
(get-buffer-create " *FQM Outgoing Email Spray*")))
;; not life's most efficient methodology, but spraying isn't
;; improvement using user-mail-address suggested by
;; firstname.lastname@example.org (Douglas Gray Stephens)
((eq t feedmail-from-line)
- (let ((feedmail-from-line
+ (let ((feedmail-from-line
feedmail-message-id-suffix is defined, uses user-mail-address, so be
sure it's set. If both are nil, creates a quasi-random suffix that is
probably not appropriate for you."
">in-> feedmail-default-message-id-generator %s" maybe-file)
(end-stuff (if feedmail-message-id-suffix
(feedmail-say-debug ">in-> feedmail-fill-to-cc-function")
(let ((case-fold-search t)
(headers (mapconcat #'regexp-quote
- '("FROM:" "REPLY-TO:" "TO:" "CC:" "BCC"
+ '("FROM:" "REPLY-TO:" "TO:" "CC:" "BCC"
"RESENT-TO:" "RESENT-CC:" "RESENT-BCC:")
(while (re-search-forward "\\s-+" (1- this-line-end) t)
(subst-char-in-region this-line this-line-end ? 2 t) ; blank->C-b
(subst-char-in-region this-line this-line-end ?, ? t) ; comma->blank
(fill-region-as-paragraph this-line this-line-end)
(subst-char-in-region this-line this-line-end ? ?, t) ; comma<-blank
(subst-char-in-region this-line this-line-end 2 ? t) ; blank<-C-b
;; look out for missing commas before continuation lines
(while (re-search-forward "\\([^,]\\)\n\t[ ]*" this-line-end t)