changeset 42225:8ef1ae58dc29

(smtpmail-send-queued-mail): Use with-temp-buffer instead of find-file-noselect, and bind coding-system-for-read to no-conversion when reading the queued messages. From Simon Josefsson <jas@extundo.com>.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 21 Dec 2001 12:06:21 +0000
parents 9709e1618364
children 628f58aa32fd
files lisp/mail/smtpmail.el
diffstat 1 files changed, 15 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/smtpmail.el	Fri Dec 21 11:40:15 2001 +0000
+++ b/lisp/mail/smtpmail.el	Fri Dec 21 12:06:21 2001 +0000
@@ -367,11 +367,11 @@
 (defun smtpmail-send-queued-mail ()
   "Send mail that was queued as a result of setting `smtpmail-queue-mail'."
   (interactive)
-  ;;; Get index, get first mail, send it, get second mail, etc...
-  (let ((buffer-index (find-file-noselect smtpmail-queue-index))
-	(file-msg "")
-	(tembuf nil))
-    (with-current-buffer buffer-index
+  (with-temp-buffer
+    ;;; Get index, get first mail, send it, update index, get second
+    ;;; mail, send it, etc...
+    (let ((file-msg ""))
+      (insert-file-contents smtpmail-queue-index)
       (beginning-of-buffer)
       (while (not (eobp))
 	(setq file-msg (buffer-substring (point) (line-end-position)))
@@ -379,20 +379,18 @@
 	;; Insert the message literally: it is already encoded as per
 	;; the MIME headers, and code conversions might guess the
 	;; encoding wrongly.
-	(setq tembuf (find-file-noselect file-msg nil t))
-	(if (not (null smtpmail-recipient-address-list))
-	    (if (not (smtpmail-via-smtp smtpmail-recipient-address-list 
-					tembuf))
-		(error "Sending failed; SMTP protocol error"))
-	  (error "Sending failed; no recipients"))  
+	(with-temp-buffer
+	  (let ((coding-system-for-read 'no-conversion))
+	    (insert-file-contents file-msg))
+	  (if (not (null smtpmail-recipient-address-list))
+	      (if (not (smtpmail-via-smtp smtpmail-recipient-address-list
+					  (current-buffer)))
+		  (error "Sending failed; SMTP protocol error"))
+	    (error "Sending failed; no recipients")))
 	(delete-file file-msg)
 	(delete-file (concat file-msg ".el"))
-	(kill-buffer tembuf)
-	(kill-line 1))      
-      (set-buffer buffer-index)
-      (save-buffer smtpmail-queue-index)
-      (kill-buffer buffer-index)
-      )))
+	(kill-line 1))
+      (write-region (point-min) (point-max) smtpmail-queue-index))))
 
 ;(defun smtpmail-via-smtp (host,port,sender,destination,smtpmail-text-buffer)