;;; feedmail.el --- assist other email packages to massage outgoing messages
;;; This file is in the public domain.
+;; This file is part of GNU Emacs.
+
+;; Author: Bill Carpenter <bill@carpenter.ORG>
+;; Version: 8
+;; Keywords: email, queue, mail, sendmail, message, spray, smtp, draft
+;; X-URL: <URL:http://www.carpenter.org/feedmail/feedmail.html>
+
;;; Commentary:
;; A replacement for parts of Emacs' sendmail.el (specifically,
;; this specific piece of code. No warranty or promise of support is
;; offered. This code is hereby released into the public domain.
-;; Author: Bill Carpenter <bill@bubblegum.net>, <bill@carpenter.ORG>
-;; Version: 8
-;; Keywords: email, queue, mail, sendmail, message, spray, smtp, draft
-;; Where: <URL:http://www.carpenter.org/feedmail/feedmail.html>
;; Thanks: My thanks to the many people who have sent me suggestions
;; and fixes over time, as well as those who have tested many beta
;; iterations. Some are cited in comments in code fragments below,
(defconst feedmail-patch-level "8")
-
-;; from <URL:http://www.dina.kvl.dk/~abraham/custom/>:
-;; If you write software that must work without the new custom, you
-;; can use this hack stolen from w3-cus.el:
-(eval-and-compile
- (condition-case ()
- (require 'custom)
- (error nil))
- (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
- nil ;; We've got what we needed
- ;; We have the old custom-library, hack around it!
- (defmacro defgroup (&rest args)
- nil)
- (defmacro defcustom (var value doc &rest args)
- (` (defvar (, var) (, value) (, doc))))))
-
+(eval-when-compile (require 'smtpmail) (require 'cl))
+(autoload 'mail-do-fcc "sendmail")
(defgroup feedmail nil
"Assist other email packages to massage outgoing messages."
+ :link '(url-link "http://www.carpenter.org/feedmail/feedmail.html")
+ :link '(emacs-commentary-link "feedmail")
:group 'mail)
(defgroup feedmail-misc nil
looking at the top of the message in a buffer when you get the prompt.
If set to the symbol 'queued, give the confirmation prompt only while
running the queue (however, the prompt is always suppressed if you are
-processing the queue via feedmail-run-the-queue-no-prompts). If set
+processing the queue via `feedmail-run-the-queue-no-prompts'). If set
to the symbol 'immediate, give the confirmation prompt only when
sending immediately. For any other non-nil value, prompt in both
cases. You can give a timeout for the prompt; see variable
-feedmail-confirm-outgoing-timeout."
+`feedmail-confirm-outgoing-timeout'."
:group 'feedmail-misc
:type 'boolean
)
"*If non-nil, a timeout in seconds at the send confirmation prompt.
If a positive number, it's a timeout before sending. If a negative
number, it's a timeout before not sending. This will not work if your
-version of Emacs doesn't include the function y-or-n-p-with-timeout
+version of Emacs doesn't include the function `y-or-n-p-with-timeout'
\(e.g., some versions of XEmacs\)."
:group 'feedmail-misc
:type '(choice (const nil) integer)
"*If non-nil remove Bcc: lines from the message headers.
In any case, the Bcc: lines do participate in the composed address
list. You may want to leave them in if you're using sendmail
-\(see feedmail-buffer-eating-function\)."
+\(see `feedmail-buffer-eating-function'\)."
:group 'feedmail-headers
:type 'boolean
)
"*If non-nil remove Resent-Bcc: lines from the message headers.
In any case, the Resent-Bcc: lines do participate in the composed
address list. You may want to leave them in if you're using sendmail
-\(see feedmail-buffer-eating-function\)."
+\(see `feedmail-buffer-eating-function'\)."
:group 'feedmail-headers
:type 'boolean
)
(defcustom feedmail-fill-to-cc-fill-column default-fill-column
- "*Fill column used by feedmail-fill-to-cc."
+ "*Fill column used by `feedmail-fill-to-cc'."
:group 'feedmail-headers
:type 'integer
)
(defcustom feedmail-nuke-body-in-fcc nil
"*If non-nil remove body of message in copies saved via Fcc:.
-If an positive integer value, leave (up to) that many lines of the
+If a positive integer value, leave (up to) that many lines of the
beginning of the body intact. The result is that the Fcc: copy will
consist only of the message headers, serving as a sort of an outgoing
message log."
:group 'feedmail-headers
- ;;:type 'boolean
:type '(choice (const nil) (const t) integer)
)
should be just the contents of the header, not the name of the header
itself nor the trailing newline. If a function, it will be called
with no arguments. For an explanation of fiddle-plexes, see the
-documentation for the variable feedmail-fiddle-plex-blurb. In all
+documentation for the variable `feedmail-fiddle-plex-blurb'. In all
cases the name element of the fiddle-plex is ignored and is hardwired
by feedmail to either \"X-Sender\" or \"X-Resent-Sender\".
(defcustom feedmail-force-binary-write t
"*If non-nil, force writing file as binary (this applies to queues and Fcc:).
On systems where there is a difference between binary and text files,
-feedmail will temporarily manipulate the values of `buffer-file-type'
-and/or default-buffer-file-type to make the writing as binary. If
-nil, writing will be in text mode. On systems where there is no
-distinction or where it is controlled by other variables or other
-means, this option has no effect."
+feedmail will temporarily manipulate the value of `buffer-file-type'
+to make the writing as binary. If nil, writing will be in text mode.
+On systems where there is no distinction or where it is controlled by other
+variables or other means, this option has no effect."
:group 'feedmail-misc
:type 'boolean
)
should be just the contents of the header, not the name of the header
itself nor the trailing newline. If a function, it will be called
with no arguments. For an explanation of fiddle-plexes, see the
-documentation for the variable feedmail-fiddle-plex-blurb. In all
+documentation for the variable `feedmail-fiddle-plex-blurb'. In all
cases the name element of the fiddle-plex is ignored and is hardwired
by feedmail to either \"X-From\" or \"X-Resent-From\".
is being sent. If there is no Sender: header, use the From: header,
if any. Address values are taken from the actual message just before
it is sent, and the process is independent of the values of
-feedmail-from-line and/or feedmail-sender-line.
+`feedmail-from-line' and/or `feedmail-sender-line'.
There are many and good reasons for having the message header
From:/Sender: be different from the message envelope \"from\"
should be just the contents of the header, not the name of the header
itself nor the trailing newline. If a function, it will be called
with no arguments. For an explanation of fiddle-plexes, see the
-documentation for the variable feedmail-fiddle-plex-blurb. In all
+documentation for the variable `feedmail-fiddle-plex-blurb'. In all
cases the name element of the fiddle-plex is ignored and is hardwired
by feedmail to either \"X-Mailer\" or \"X-Resent-Mailer\"."
:group 'feedmail-headers
itself nor the trailing newline. If a function, it will be called
with one argument: the possibly-nil name of the file associated with
the message buffer. For an explanation of fiddle-plexes, see the
-documentation for the variable feedmail-fiddle-plex-blurb. In all
+documentation for the variable `feedmail-fiddle-plex-blurb'. In all
cases the name element of the fiddle-plex is ignored and is hardwired
by feedmail to either \"Message-Id\" or \"Resent-Message-Id\".
probably won't hurt you to generate your own, and it will then show up
in the saved message if you use Fcc:."
:group 'feedmail-headers
- :type '(choice (const nil) function)
+ :type '(choice (const t) (const nil) function)
)
If t, a Date: header of a predetermined format is produced, but only
if there is not already a Date: in the message. A value of t is
-equivalent to using the function feedmail-default-date-generator.
+equivalent to using the function `feedmail-default-date-generator'.
If neither nil nor t, it may be a string, a fiddle-plex, or a function
which returns either nil, t, a string, or a fiddle-plex (or, in fact,
itself nor the trailing newline. If a function, it will be called
with one argument: the possibly-nil name of the file associated with
the message buffer. For an explanation of fiddle-plexes, see the
-documentation for the variable feedmail-fiddle-plex-blurb. In all
+documentation for the variable `feedmail-fiddle-plex-blurb'. In all
cases the name element of the fiddle-plex is ignored and is hardwired
by feedmail to either \"Date\" or \"Resent-Date\".
probably won't hurt you to generate your own, and it will then show up
in the saved message if you use Fcc:."
:group 'feedmail-headers
- :type '(choice (const nil) function)
+ :type '(choice (const t) (const nil) function)
)
(defcustom feedmail-fiddle-headers-upwardly t
"*Non-nil means fiddled header fields should go at the top of the header.
-Nil means insert them at the bottom. This is mostly a novelty issue since
+nil means insert them at the bottom. This is mostly a novelty issue since
the standards define the ordering of header fields to be immaterial and it's
fairly likely that some MTA along the way will have its own idea of what the
order should be, regardless of what you specify."
- :group 'feedmail-header
+ :group 'feedmail-headers
:type 'boolean
)
feedmail will use this list of fiddle-plexes to manipulate user-specified
message header fields. It does this after it has completed all normal
-message header field manipulation and before calling feedmail-last-chance-hook.
+message header field manipulation and before calling `feedmail-last-chance-hook'.
For an explanation of fiddle-plexes, see the documentation for the
-variable feedmail-fiddle-plex-blurb. In contrast to some other fiddle-plex
+variable `feedmail-fiddle-plex-blurb'. In contrast to some other fiddle-plex
manipulation functions, in this context, it makes no sense to have an element
which is nil, t, or a simple string."
- :group 'feedmail-header
+ :group 'feedmail-headers
:type '(repeat (choice function)
sexp) ; too complex to be described accurately
)
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
-which see feedmail-spray-address-fiddle-plex-list.
+which see `feedmail-spray-address-fiddle-plex-list'.
If one of the calls to the buffer-eating function results in an error,
what happens next is carelessly defined, so beware."
)
(defvar feedmail-spray-this-address nil
- "Do not set or change this variable. See feedmail-spray-address-fiddle-plex-list.")
+ "Do not set or change this variable. See `feedmail-spray-address-fiddle-plex-list'.")
(defcustom feedmail-spray-address-fiddle-plex-list nil
"User-supplied specification for a crude form of mailmerge capability.
When spraying is enabled, feedmail composes a list of envelope addresses.
-In turn, feedmail-spray-this-address is temporarily set to each address
+In turn, `feedmail-spray-this-address' is temporarily set to each address
\(stripped of any comments and angle brackets\) and calls a function which
fiddles message headers according to this variable. See the documentation for
`feedmail-fiddle-plex-blurb', for an overview of fiddle-plex data structures.
The idea of the example is that, during spray mode, as each message is
about to be transmitted to an individual address, the function will be
-called and will consult feedmail-spray-this-address to find the
+called and will consult `feedmail-spray-this-address' to find the
stripped envelope email address (no comments or angle brackets). The
function should return an embellished form of the address.
The recipe for sending form letters is: (1) create a message with all
addressees on Bcc: headers; (2) tell feedmail to remove Bcc: headers
before sending the message; (3) create a function which will embellish
-stripped addresses, if desired; (4) define feedmail-spray-address-fiddle-plex-list
-appropriately; (5) send the message with feedmail-enable-spray set
+stripped addresses, if desired; (4) define `feedmail-spray-address-fiddle-plex-list'
+appropriately; (5) send the message with `feedmail-enable-spray' set
non-nil; (6) stand back and watch co-workers wonder at how efficient
you are at accomplishing inherently inefficient things."
:group 'feedmail-spray
directory you want at the prompt. The right thing will happen.
To transmit all the messages in the queue, invoke the command
-feedmail-run-the-queue or feedmail-run-the-queue-no-prompts."
+`feedmail-run-the-queue' or `feedmail-run-the-queue-no-prompts'."
:group 'feedmail-queue
:type 'boolean
)
(defcustom feedmail-queue-runner-confirm-global nil
"*If non-nil, give a y-or-n confirmation prompt before running the queue.
Prompt even if the queue is about to be processed as a result of a call to
-feedmail-run-the-queue-no-prompts. This gives you a way to bail out
+`feedmail-run-the-queue-no-prompts'. This gives you a way to bail out
without having to answer no to the individual message prompts."
:group 'feedmail-queue
:type 'boolean)
-;; I provided a default for VMS because someone asked for it (the
-;; normal default doesn't work there), but, puh-lease!, it is a user
-;; definable option, so if you don't like the default, change it to
-;; whatever you want. I am unable to directly test the VMS goop
-;; provided here by levitte@lp.se (Richard Levitte - VMS Whacker).
(defcustom feedmail-queue-directory
- (if (memq system-type '(axp-vms vax-vms))
- (expand-file-name (concat (getenv "HOME") "[.MAIL.Q]"))
- (concat (getenv "HOME") "/mail/q"))
+ (concat (getenv "HOME") "/mail/q")
"*Name of a directory where messages will be queued.
Directory will be created if necessary. Should be a string that
-doesn't end with a slash. Default, except on VMS, is \"$HOME/mail/q\"."
+doesn't end with a slash. Default is \"$HOME/mail/q\"."
:group 'feedmail-queue
:type 'string
)
(defcustom feedmail-queue-draft-directory
- (if (memq system-type '(axp-vms vax-vms))
- (expand-file-name (concat (getenv "HOME") "[.MAIL.DRAFT]"))
- (concat (getenv "HOME") "/mail/draft"))
- "*Name of an directory where draft messages will be queued.
+ (concat (getenv "HOME") "/mail/draft")
+ "*Name of a directory where draft messages will be queued.
Directory will be created if necessary. Should be a string that
-doesn't end with a slash. Default, except on VMS, is \"$HOME/mail/draft\"."
+doesn't end with a slash. Default is \"$HOME/mail/draft\"."
:group 'feedmail-queue
:type 'string
)
(defcustom feedmail-ask-before-queue-prompt "FQM: Message action (q, i, d, e, ?)? [%s]: "
"*A string which will be used for the message action prompt.
If it contains a \"%s\", that will be replaced with the value of
-feedmail-ask-before-queue-default."
+`feedmail-ask-before-queue-default'."
:group 'feedmail-queue
:type 'string
)
(defcustom feedmail-ask-before-queue-reprompt "FQM: Please type q, i, d, or e; or ? for help [%s]: "
"*A string which will be used for repompting after invalid input.
If it contains a \"%s\", that will be replaced with the value of
-feedmail-ask-before-queue-default."
+`feedmail-ask-before-queue-default'."
:group 'feedmail-queue
:type 'string
)
All of the values are function names, except help, which is a special
symbol that calls up help for the prompt (the help describes the
actions from the standard alist). To customize your own choices,
-define a similar alist called feedmail-prompt-before-queue-user-alist.
+define a similar alist called `feedmail-prompt-before-queue-user-alist'.
The actual alist used for message action will be the standard alist
overlaid with the user-alist. To neutralize an item in the standard
alist without providing a replacement, define an appropriate element
(defcustom feedmail-prompt-before-queue-user-alist nil
- "See feedmail-prompt-before-queue-standard-alist."
+ "See `feedmail-prompt-before-queue-standard-alist'."
:group 'feedmail-queue
:type '(repeat (cons character function))
)
When the message action prompt is shown, the user can as for verbose help,
at which point a buffer pops up describing the meaning of possible
responses to the prompt. Through various customizations (see, for
-example, feedmail-prompt-before-queue-user-alist), the available responses
+example, `feedmail-prompt-before-queue-user-alist'), the available responses
and the prompt itself can be changed. If this variable is set to a string
value, that string is written to the help buffer after the standard info.
-It may contain embedded line breaks. It will be printed via princ."
+It may contain embedded line breaks. It will be printed via `princ'."
:group 'feedmail-queue
:type '(choice (const nil) string)
)
(after-draft . feedmail-queue-reminder-medium)
(after-run . feedmail-queue-reminder-brief)
(on-demand . feedmail-run-the-queue-global-prompt))
- "See feedmail-queue-reminder."
+ "See `feedmail-queue-reminder'."
:group 'feedmail-queue
:type '(repeat (cons (choice :tag "Event"
(const on-demand)
(defcustom feedmail-queue-use-send-time-for-message-id nil
"*If non-nil, use send time for the Message-Id: header value.
This variable is used by the default Message-Id: generating function,
-feedmail-default-message-id-generator. If nil, the default, the
+`feedmail-default-message-id-generator'. If nil, the default, the
last-modified timestamp of the queue file is used to create the
message Message-Id: header; if there is no queue file, the current time is
used."
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
-function feedmail-queue-subject-slug-maker.
+function `feedmail-queue-subject-slug-maker'.
If t, an innocuous default is used.
"*The FQM suffix used to distinguish feedmail queued message files.
You probably want this to be a period followed by some letters and/or
digits. The distinction is to be able to tell them from other random
-files that happen to be in the feedmail-queue-directory or
-feedmail-queue-draft-directory. By the way, FQM stands for feedmail
+files that happen to be in the `feedmail-queue-directory' or
+`feedmail-queue-draft-directory'. By the way, FQM stands for feedmail
queued message."
:group 'feedmail-queue
:type 'string
(defvar feedmail-address-list nil)
+(defvar feedmail-queue-runner-is-active nil
+ "*Non-nil means we're inside the logic of the queue-running loop.
+That is, iterating over all messages in the queue to send them. In
+that case, the value is the name of the queued message file currently
+being processed. This can be used for differentiating customized code
+for different scenarios. Users shouldn't set or change this
+variable, but may depend on its value as described here.")
+
+
(defun feedmail-mail-send-hook-splitter ()
- "Facilitate dividing mail-send-hook things into queued and immediate cases.
-If you have mail-send-hook functions that should only be called for sending/
+ "Facilitate dividing `mail-send-hook' things into queued and immediate cases.
+If you have `mail-send-hook' functions that should only be called for sending/
queueing messages or only be called for the sending of queued messages, this is
-for you. Add this function to mail-send-hook with something like this:
+for you. Add this function to `mail-send-hook' with something like this:
(add-hook 'mail-send-hook 'feedmail-mail-send-hook-splitter)
-Then add the functions you want called to either feedmail-mail-send-hook-queued
-or feedmail-mail-send-hook, as apprpriate. The distinction is that
-feedmail-mail-send-hook will be called when you send mail from a composition
+Then add the functions you want called to either `feedmail-mail-send-hook-queued'
+or `feedmail-mail-send-hook', as apprpriate. The distinction is that
+`feedmail-mail-send-hook' will be called when you send mail from a composition
buffer (typically by typing C-c C-c), whether the message is sent immediately
-or placed in the queue or drafts directory. feedmail-mail-send-hook-queued is
+or placed in the queue or drafts directory. `feedmail-mail-send-hook-queued' is
called when messages are being sent from the queue directory, typically via a
-call to feedmail-run-the-queue."
+call to `feedmail-run-the-queue'."
(if feedmail-queue-runner-is-active
(run-hooks 'feedmail-mail-send-hook-queued)
(run-hooks 'feedmail-mail-send-hook))
(defvar feedmail-mail-send-hook nil
- "*See documentation for feedmail-mail-send-hook-splitter.")
+ "*See documentation for `feedmail-mail-send-hook-splitter'.")
(defvar feedmail-mail-send-hook-queued nil
- "*See documentation for feedmail-mail-send-hook-splitter.")
+ "*See documentation for `feedmail-mail-send-hook-splitter'.")
(defun feedmail-confirm-addresses-hook-example ()
- "An example of a feedmail-last-chance-hook.
+ "An example of a `feedmail-last-chance-hook'.
It shows the simple addresses and gets a confirmation. Use as:
(setq feedmail-last-chance-hook 'feedmail-confirm-addresses-hook-example)."
(save-window-excursion
It has already had all the header prepping from the standard package.
The next step after running the hook will be to push the buffer into a
subprocess that mails the mail. The hook might be interested in
-these: (1) feedmail-prepped-text-buffer contains the header and body
-of the message, ready to go; (2) feedmail-address-list contains a list
+these: (1) `feedmail-prepped-text-buffer' contains the header and body
+of the message, ready to go; (2) `feedmail-address-list' contains a list
of simplified recipients of addresses which are to be given to the
-subprocess (the hook may change the list); (3) feedmail-error-buffer
+subprocess (the hook may change the list); (3) `feedmail-error-buffer'
is an empty buffer intended to soak up errors for display to the user.
If the hook allows interactive activity, the user should not send more
mail while in the hook since some of the internal buffers will be
It has already had all the header prepping from the standard package.
The next step after running the hook will be to save the message via
Fcc: processing. The hook might be interested in these: (1)
-feedmail-prepped-text-buffer contains the header and body of the
-message, ready to go; (2) feedmail-address-list contains a list of
+`feedmail-prepped-text-buffer' contains the header and body of the
+message, ready to go; (2) `feedmail-address-list' contains a list of
simplified recipients of addressees to whom the message was sent (3)
-feedmail-error-buffer is an empty buffer intended to soak up errors
+`feedmail-error-buffer' is an empty buffer intended to soak up errors
for display to the user. If the hook allows interactive activity, the
user should not send more mail while in the hook since some of the
internal buffers will be reused and things will get confused."
"*A function to set the proper mode of a message file.
Called when the message is 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.
+`feedmail-run-the-queue' or `feedmail-run-the-queue-no-prompts'.
Most people want `mail-mode', so the default value is an anonymous
function which is just a wrapper to ignore the supplied argument when
non-nil, feedmail will first try to send the message using the value
of `mail-header-separator'. If it can't find that, it will temporarily
set `mail-header-separator' to the value of
-feedmail-queue-alternative-mail-header-separator and try again."
+`feedmail-queue-alternative-mail-header-separator' and try again."
:group 'feedmail-queue
:type '(choice (const nil) string)
)
"*Function to initiate sending a message file.
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.
+`feedmail-run-the-queue' or `feedmail-run-the-queue-no-prompts'.
Interactively, that argument will be the prefix argument. Most people
-want mail-send-and-exit (bound to C-c C-c in mail-mode), but here's
-your chance to have something different. Called with funcall, not
-call-interactively."
+want `mail-send-and-exit' (bound to C-c C-c in mail-mode), but here's
+your chance to have something different. Called with `funcall', not
+`call-interactively'."
:group 'feedmail-queue
:type 'function
)
)
-(defvar feedmail-queue-runner-is-active nil
- "*Non-nil means we're inside the logic of the queue-running loop.
-That is, iterating over all messages in the queue to send them. In
-that case, the value is the name of the queued message file currently
-being processed. This can be used for differentiating customized code
-for different scenarios. Users shouldn't set or change this
-variable, but may depend on its value as described here.")
-
-
(defvar feedmail-is-a-resend nil
- "*Non-nil means the the message is a Resend (in the RFC-822 sense).
+ "*Non-nil means the message is a Resend (in the RFC-822 sense).
This affects the composition of certain headers. feedmail sets this
variable as soon as it starts prepping the message text buffer, so any
user-supplied functions can rely on it. Users shouldn't set or change this
containing the prepped message; (2) a buffer where errors should be
directed; and (3) a list containing the addresses individually as
strings. Three popular choices for this are
-feedmail-buffer-to-binmail, feedmail-buffer-to-smtpmail, and
-feedmail-buffer-to-sendmail. If you use the sendmail form, you
-probably want to set feedmail-nuke-bcc and/or feedmail-nuke-resent-bcc
+`feedmail-buffer-to-binmail', `feedmail-buffer-to-smtpmail', and
+`feedmail-buffer-to-sendmail'. If you use the sendmail form, you
+probably want to set `feedmail-nuke-bcc' and/or `feedmail-nuke-resent-bcc'
to nil. If you use the binmail form, check the value of
-feedmail-binmail-template."
+`feedmail-binmail-template'."
:group 'feedmail-misc
:type 'function
)
It can result in any command understandable by /bin/sh. Might not
work at all in non-Unix environments. The single '%s', if present,
gets replaced by the space-separated, simplified list of addressees.
-Used in feedmail-buffer-to-binmail to form the shell command which
+Used in `feedmail-buffer-to-binmail' to form the shell command which
will receive the contents of the prepped buffer as stdin. If you'd
like your errors to come back as mail instead of immediately in a
buffer, try /bin/rmail instead of /bin/mail (this can be accomplished
(set-buffer prepped)
(apply 'call-process-region
(append (list (point-min) (point-max)
- (if (boundp 'sendmail-program) sendmail-program "/usr/lib/sendmail")
+ (cond ((boundp 'sendmail-program)
+ sendmail-program)
+ ((file-exists-p "/usr/sbin/sendmail")
+ "/usr/sbin/sendmail")
+ ((file-exists-p "/usr/lib/sendmail")
+ "/usr/lib/sendmail")
+ ((file-exists-p "/usr/ucblib/sendmail")
+ "/usr/ucblib/sendmail")
+ (t "fakemail"))
nil errors-to nil "-oi" "-t")
;; provide envelope "from" to sendmail; results will vary
(list "-f" user-mail-address)
;; Mon 14-Oct-1996; Douglas Gray Stephens
;; modified to insert error for displaying
(defun feedmail-buffer-to-smtpmail (prepped errors-to addr-listoid)
- "Function which actually calls smtpmail-via-smtp to send buffer as e-mail."
+ "Function which actually calls `smtpmail-via-smtp' to send buffer as e-mail."
;; I'm not sure smtpmail.el is careful about the following
;; return value, but it also uses it internally, so I will fear
;; no evil.
(if (string-match tracer (buffer-name buffy))
(progn
(insert "SMTP Trace from " (buffer-name buffy) "\n---------------")
- (insert-buffer buffy)
+ (insert-buffer-substring buffy)
(insert "\n\n"))))
(buffer-list))))))
non-nil, feedmail \"smart filling\" is done on VALUE just before
insertion.")
-
+;;;###autoload
(defun feedmail-send-it ()
- "A function which is a suitable value for `send-mail-function'.
-To use it, you probably want something like this in your .emacs or
-similar place:
-
- (setq send-mail-function 'feedmail-send-it)
- (autoload 'feedmail-send-it \"feedmail\")"
+ "Send the current mail buffer using the Feedmail package.
+This is a suitable value for `send-mail-function'. It can be used
+with various lower-level mechanisms to provide features such as queueing."
;; avoid matching trouble over slash vs backslash by getting canonical
(if feedmail-queue-directory
;;;###autoload
(defun feedmail-run-the-queue-no-prompts (&optional arg)
- "Like feedmail-run-the-queue, but suppress confirmation prompts."
+ "Like `feedmail-run-the-queue', but suppress confirmation prompts."
(interactive "p")
(let ((feedmail-confirm-outgoing nil)) (feedmail-run-the-queue arg)))
;;;###autoload
(defun feedmail-run-the-queue-global-prompt (&optional arg)
- "Like feedmail-run-the-queue, but with a global confirmation prompt.
+ "Like `feedmail-run-the-queue', but with a global confirmation prompt.
This is generally most useful if run non-interactively, since you can
bail out with an appropriate answer to the global confirmation prompt."
(interactive "p")
(let ((feedmail-queue-runner-confirm-global t)) (feedmail-run-the-queue arg)))
+;; letf fools the byte-compiler.
+(defvar file-name-buffer-file-type-alist)
+
;;;###autoload
(defun feedmail-run-the-queue (&optional arg)
"Visit each message in the feedmail queue directory and send it out.
(setq list-of-possible-fqms (directory-files feedmail-queue-directory t))
(if feedmail-queue-run-orderer
(setq list-of-possible-fqms (funcall feedmail-queue-run-orderer list-of-possible-fqms)))
- (mapcar
+ (mapc
'(lambda (blobby)
(setq maybe-file (expand-file-name blobby feedmail-queue-directory))
(cond
(not
(let ((mail-header-separator feedmail-queue-alternative-mail-header-separator))
(feedmail-find-eoh t)))))
- (let ((file-name-buffer-file-type-alist nil) (default-buffer-file-type nil))
- (erase-buffer) (insert-file-contents maybe-file))
- )
+ (letf ((file-name-buffer-file-type-alist nil)
+ ((default-value 'buffer-file-type) nil))
+ (erase-buffer) (insert-file-contents maybe-file)))
;; if M-H-S not found and (a-M-H-S is non-nil and is found)
;; temporarily set M-H-S to the value of a-M-H-S
(if (and (not (feedmail-find-eoh t))
"Perform some kind of reminder activity about queued and draft messages.
Called with an optional symbol argument which says what kind of event
is triggering the reminder activity. The default is 'on-demand, which
-is what you typically would use if you were putting this in your emacs start-up
+is what you typically would use if you were putting this in your Emacs start-up
or mail hook code. Other recognized values for WHAT-EVENT (these are passed
internally by feedmail):
after-draft (a message has just been placed in the draft directory)
after-run (the queue has just been run, possibly sending messages)
-WHAT-EVENT is used as a key into the table feedmail-queue-reminder-alist. If
+WHAT-EVENT is used as a key into the table `feedmail-queue-reminder-alist'. If
the associated value is a function, it is called without arguments and is expected
to perform the reminder activity. You can supply your own reminder functions
-by redefining feedmail-queue-reminder-alist. If you don't want any reminders,
-you can set feedmail-queue-reminder-alist to nil."
+by redefining `feedmail-queue-reminder-alist'. If you don't want any reminders,
+you can set `feedmail-queue-reminder-alist' to nil."
(interactive "p")
(let ((key (if (and what-event (symbolp what-event)) what-event 'on-demand)) entry reminder)
(setq entry (assoc key feedmail-queue-reminder-alist))
(defun feedmail-queue-send-edit-prompt-help (d-string)
(let ((fqm-help (get-buffer feedmail-p-h-b-n)))
- (if (and fqm-help (get-buffer-window fqm-help))
+ (if (and fqm-help (get-buffer-window fqm-help 'visible))
(feedmail-queue-send-edit-prompt-help-later fqm-help d-string)
(feedmail-queue-send-edit-prompt-help-first d-string))))
(let ((q-cnt 0) (q-oth 0) (high-water 0) (blobbet))
;; iterate, counting things we find along the way in the directory
(if (file-directory-p queue-directory)
- (mapcar
+ (mapc
'(lambda (blobby)
(cond
((file-directory-p blobby) nil) ; don't care about subdirs
(setq blobbet (file-name-nondirectory blobby))
(if (string-match "^[0-9][0-9][0-9]-" blobbet)
(let ((water-mark))
- (setq water-mark (string-to-int (substring blobbet 0 3)))
+ (setq water-mark (string-to-number (substring blobbet 0 3)))
(if (> water-mark high-water) (setq high-water water-mark))))
(setq q-cnt (1+ q-cnt)))
(t (setq q-oth (1+ q-oth)))
Optional argument QUEUE-DIRECTORY specifies into which directory the
file will be placed. The name is based on the Subject: header (if
there is one). If there is no subject,
-feedmail-queue-default-file-slug is consulted Special characters are
+`feedmail-queue-default-file-slug' is consulted. Special characters are
mapped to mostly alphanumerics for safety."
(let ((eoh-marker) (case-fold-search t) (subject "") (s-point))
(setq eoh-marker (feedmail-find-eoh))
;; progn to get nil result no matter what
(progn (make-directory queue-directory t) nil)
(file-accessible-directory-p queue-directory)
- (error (concat "FQM: Message not queued; trouble with directory " queue-directory)))
+ (error "FQM: Message not queued; trouble with directory %s" queue-directory))
(let ((filename)
(is-fqm)
(is-in-this-dir)
(setq filename buffer-file-name)
(setq filename (feedmail-create-queue-filename queue-directory)))
;; make binary file on DOS/Win95/WinNT, etc
- (let ((buffer-file-type feedmail-force-binary-write)) (write-file filename))
+ (let ((buffer-file-type feedmail-force-binary-write))
+ (write-file filename))
;; convenient for moving from draft to q, for example
(if (and previous-buffer-file-name (or (not is-fqm) (not is-in-this-dir))
(y-or-n-p (format "FQM: Was previously %s; delete that? " previous-buffer-file-name)))
(file-exists-p a-s-file-name)
(delete-file a-s-file-name))))
(if feedmail-queue-chatty
- (progn (message (concat "FQM: Queued in " filename))
+ (progn (message "%s" (concat "FQM: Queued in " filename))
(sit-for feedmail-queue-chatty-sit-for)))
(if feedmail-queue-chatty
(progn
(set-buffer feedmail-prepped-text-buffer) (erase-buffer)
;; jam contents of user-supplied mail buffer into our scratch buffer
- (insert-buffer feedmail-raw-text-buffer)
+ (insert-buffer-substring feedmail-raw-text-buffer)
;; require one newline at the end.
(goto-char (point-max))
)))
(goto-char (point-min))
;; re-insert and handle any Fcc fields (and, optionally, any Bcc).
- (if fcc (let ((default-buffer-file-type feedmail-force-binary-write))
+ (if fcc (letf (((default-value 'buffer-file-type)
+ feedmail-force-binary-write))
(insert fcc)
(if (not feedmail-nuke-bcc-in-fcc)
(progn (if bcc-holder (insert bcc-holder))
"Internal feedmail function for jamming fields into message header.
NAME, VALUE, ACTION, and FOLDING are the four elements of a
fiddle-plex, as described in the documentation for the variable
-feedmail-fiddle-plex-blurb."
+`feedmail-fiddle-plex-blurb'."
(let ((case-fold-search t)
(header-colon (concat (regexp-quote name) ":"))
header-regexp eoh-marker has-like ag-like val-like that-point)
(erase-buffer)
;; not life's most efficient methodology, but spraying isn't
;; an every-5-minutes event either
- (insert-buffer feedmail-prepped-text-buffer)
+ (insert-buffer-substring feedmail-prepped-text-buffer)
;; There's a good case to me made that each separate transmission of
;; a message in the spray should have a distinct Message-Id:. There
;; is also a less compelling argument in the other direction. I think
(defun feedmail-envelope-deducer (eoh-marker)
- "If feedmail-deduce-envelope-from is false, simply return `user-mail-address'.
+ "If `feedmail-deduce-envelope-from' is false, simply return `user-mail-address'.
Else, look for Sender: or From: (or Resent-*) and
return that value."
(if (not feedmail-deduce-envelope-from)
(defun feedmail-fiddle-date (maybe-file)
- "Fiddle Date:. See documentation of feedmail-date-generator."
+ "Fiddle Date:. See documentation of `feedmail-date-generator'."
;; default is to fall off the end of the list and do nothing
(cond
;; nil means do nothing
(defun feedmail-default-message-id-generator (maybe-file)
"Default function for generating Message-Id: header contents.
Based on a date and a sort of random number for tie breaking. Unless
-feedmail-message-id-suffix is defined, uses `user-mail-address', so be
+`feedmail-message-id-suffix' is defined, uses `user-mail-address', so be
sure it's set."
(let ((date-time)
(end-stuff (if feedmail-message-id-suffix feedmail-message-id-suffix user-mail-address)))
)
(defun feedmail-fiddle-message-id (maybe-file)
- "Fiddle Message-Id:. See documentation of feedmail-message-id-generator."
+ "Fiddle Message-Id:. See documentation of `feedmail-message-id-generator'."
;; default is to fall off the end of the list and do nothing
(cond
;; nil means do nothing
(defun feedmail-fiddle-x-mailer ()
- "Fiddle X-Mailer:. See documentation of feedmail-x-mailer-line."
+ "Fiddle X-Mailer:. See documentation of `feedmail-x-mailer-line'."
;; default is to fall off the end of the list and do nothing
(cond
;; t is the same a using the function feedmail-default-x-mailer-generator, so let it and recurse
(defun feedmail-fiddle-spray-address (addy-plex)
- "Fiddle header for single spray address. Uses feedmail-spray-this-address."
+ "Fiddle header for single spray address. Uses `feedmail-spray-this-address'."
;; default is to fall off the end of the list and do nothing
(cond
;; nil means do nothing
(defun feedmail-deduce-address-list (message-buffer header-start header-end addr-regexp address-list)
"Get address list with all comments and other excitement trimmed.
Addresses are collected only from headers whose names match the fourth
-argument Returns a list of strings. Duplicate addresses will have
+argument. Returns a list of strings. Duplicate addresses will have
been weeded out."
(let ((simple-address)
(address-blob)
"Internal; finds the end of message header fields, returns mark just before it"
(save-excursion
(goto-char (point-min))
- (if (re-search-forward (concat "^" (regexp-quote mail-header-separator) "\n") nil noerror)
- (progn
- (forward-line -1)
- (point-marker)))))
+ (when (or (re-search-forward (concat "^"
+ (regexp-quote mail-header-separator)
+ "\n")
+ nil noerror)
+ (and feedmail-queue-alternative-mail-header-separator
+ (re-search-forward
+ (concat "^"
+ (regexp-quote
+ feedmail-queue-alternative-mail-header-separator)
+ "\n")
+ nil noerror)))
+ (forward-line -1)
+ (point-marker))))
(provide 'feedmail)
+
+;; arch-tag: ec27b380-11c0-4dfd-8436-f636cf2bb992
;;; feedmail.el ends here