1 ;;; smtpmail-async --- Send e-mail with smtpmail.el asynchronously
3 ;; Copyright (C) 2012~2014 John Wiegley
5 ;; Author: John Wiegley <jwiegley@gmail.com>
6 ;; Created: 18 Jun 2012
8 ;; Keywords: email async
9 ;; X-URL: https://github.com/jwiegley/emacs-async
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; Send e-mail with smtpmail.el asynchronously. To use:
30 ;; (require 'smtpmail-async)
32 ;; (setq send-mail-function 'async-smtpmail-send-it
33 ;; message-send-mail-function 'async-smtpmail-send-it)
35 ;; This assumes you already have smtpmail.el working.
37 (defgroup smtpmail-async nil
38 "Send e-mail with smtpmail.el asynchronously"
44 (defun async-smtpmail-send-it ()
45 (let ((to (message-field-value "To"))
46 (buf-content (buffer-substring-no-properties
47 (point-min) (point-max))))
48 (message "Delivering message to %s..." to)
54 (set-buffer-multibyte nil)
55 ;; Pass in the variable environment for smtpmail
56 ,(async-inject-variables
57 "\\`\\(smtpmail\\|\\(user-\\)?mail\\)-"
58 nil "\\`\\(mail-header-format-function\\|smtpmail-address-buffer\\|mail-mode-abbrev-table\\)")
61 `(lambda (&optional ignore)
62 (message "Delivering message to %s...done" ,to)))))
64 (provide 'smtpmail-async)
66 ;;; smtpmail-async.el ends here