]> code.delx.au - gnu-emacs-elpa/blobdiff - smtpmail-async.el
No need to require find-func.
[gnu-emacs-elpa] / smtpmail-async.el
index 76a9fb52fc6e933646ad03b857a226c23ac75f7f..99c4017b08546d407013f96322b9fe73d7e0dd9e 100644 (file)
@@ -1,10 +1,10 @@
-;;; smtpmail-async --- Send e-mail with smtpmail.el asynchronously
+;;; smtpmail-async.el --- Send e-mail with smtpmail.el asynchronously
 
 ;; Copyright (C) 2012~2014 John Wiegley
 
 ;; Author: John Wiegley <jwiegley@gmail.com>
 ;; Created: 18 Jun 2012
-;; Version: 1.0
+
 ;; Keywords: email async
 ;; X-URL: https://github.com/jwiegley/emacs-async
 
 ;;
 ;; This assumes you already have smtpmail.el working.
 
+;;; Code:
+
 (defgroup smtpmail-async nil
   "Send e-mail with smtpmail.el asynchronously"
   :group 'smptmail)
 
 (require 'async)
 (require 'smtpmail)
+(require 'message)
+
+(defvar async-smtpmail-before-send-hook nil
+  "Hook running in the child emacs in `async-smtpmail-send-it'.
+It is called just before calling `smtpmail-send-it'.")
 
 (defun async-smtpmail-send-it ()
   (let ((to          (message-field-value "To"))
@@ -54,8 +61,9 @@
           (set-buffer-multibyte nil)
           ;; Pass in the variable environment for smtpmail
           ,(async-inject-variables
-            "\\`\\(smtpmail\\|\\(user-\\)?mail\\)-"
+            "\\`\\(smtpmail\\|async-smtpmail\\|\\(user-\\)?mail\\)-\\|auth-sources\\|epg"
             nil "\\`\\(mail-header-format-function\\|smtpmail-address-buffer\\|mail-mode-abbrev-table\\)")
+          (run-hooks 'async-smtpmail-before-send-hook)
           (smtpmail-send-it)))
      `(lambda (&optional ignore)
         (message "Delivering message to %s...done" ,to)))))