branch: elpa/org-mime
commit 168fe3a6a15695c9f987ddda8eb1bdf41c849bb3
Merge: 744f5f3315 2581fc2dd9
Author: Chen Bin <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #51 from borwickatuw/master
org-mime-confirm-when-no-multipart function + docs
---
README.org | 8 ++++++++
org-mime.el | 12 ++++++++++++
2 files changed, 20 insertions(+)
diff --git a/README.org b/README.org
index f53ebdec95..66890a1f89 100644
--- a/README.org
+++ b/README.org
@@ -149,6 +149,14 @@ ASCII export options:
(setq org-mime-export-ascii 'utf-8)
#+end_src
+** Prompt for confirmation if message has no HTML
+
+If you plan to run =org-mime-htmlize= on all your email, you may want a
confirmation if it appears you're sending an email without multipart content.
To do this, add a hook to =message-send-hook= to your init file:
+
+#+begin_src elisp
+(add-hook 'message-send-hook 'org-mime-confirm-when-no-multipart)
+#+end_src
+
* Support legacy Emacs versions
- 0.1.6 is the last version to support Emacs 24
* Development
diff --git a/org-mime.el b/org-mime.el
index 28274c5f10..f2f29761dc 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -788,6 +788,18 @@ Following headline properties can determine the mail
headers,
(t
(message "Can not find plain text mail.")))))
+(defun org-mime-confirm-when-no-multipart ()
+ "Prompts whether to send email if the buffer does not seem to be html-ized"
+ (let ((found-multipart (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (search-forward "<#multipart type=alternative>"
nil t)))))
+ (when (and (not found-multipart)
+ (not (y-or-n-p "org-mime-htmlize not called; send anyway?")))
+ (setq quit-flag t))))
+
+
(provide 'org-mime)
;; Local Variables:
;; coding: utf-8