aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-06-01 23:26:16 +0000
committerRichard M. Stallman1997-06-01 23:26:16 +0000
commit308bc5d84041d767e72ce867469d3886dc3af4f3 (patch)
tree4ea3b6e99d7818806247b8d5807a906058d681a0
parentd06970e54c9842ce9a04d77d7cfabdd7c03a5888 (diff)
downloademacs-308bc5d84041d767e72ce867469d3886dc3af4f3.tar.gz
emacs-308bc5d84041d767e72ce867469d3886dc3af4f3.zip
Include time-stamp.
(smtpmail-queue-dir, smtpmail-queue-index-file): New variables. (smtpmail-queue-mail): New variable. (smtpmail-send-it): Handle those variables. (smtpmail-send-queued-mail): New command.
-rw-r--r--lisp/mail/smtpmail.el97
1 files changed, 90 insertions, 7 deletions
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index 6fa2418ce72..433c9ec7a93 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -39,9 +39,14 @@
39;;(setq smtpmail-code-conv-from nil) 39;;(setq smtpmail-code-conv-from nil)
40;;(setq user-full-name "YOUR NAME HERE") 40;;(setq user-full-name "YOUR NAME HERE")
41 41
42;; To queue mail, set smtpmail-queue-mail to t and use
43;; smtpmail-send-queued-mail to send.
44
45
42;;; Code: 46;;; Code:
43 47
44(require 'sendmail) 48(require 'sendmail)
49(require 'time-stamp)
45 50
46;;; 51;;;
47(defgroup smtpmail nil 52(defgroup smtpmail nil
@@ -82,6 +87,25 @@ don't define this value."
82 :type 'boolean 87 :type 'boolean
83 :group 'smtpmail) 88 :group 'smtpmail)
84 89
90(defcustom smtpmail-queue-mail nil
91 "*Specify if mail is queued (if t) or sent immediately (if nil).
92If queued, it is stored in the directory `smtpmail-queue-dir'
93and sent with `smtpmail-send-queued-mail'."
94 :type 'boolean
95 :group 'smtpmail)
96
97(defcustom smtpmail-queue-dir "~/Mail/queued-mail/"
98 "*Directory where `smtpmail.el' stores queued mail."
99 :type 'directory
100 :group 'smtpmail)
101
102(defvar smtpmail-queue-index-file "index"
103 "File name of queued mail index,
104This is relative to `smtpmail-queue-dir'.")
105
106(defvar smtpmail-queue-index (concat smtpmail-queue-dir
107 smtpmail-queue-index-file))
108
85;;; 109;;;
86;;; 110;;;
87;;; 111;;;
@@ -218,18 +242,77 @@ don't define this value."
218 (or resend-to-addresses 242 (or resend-to-addresses
219 (smtpmail-deduce-address-list tembuf (point-min) delimline))) 243 (smtpmail-deduce-address-list tembuf (point-min) delimline)))
220 (kill-buffer smtpmail-address-buffer) 244 (kill-buffer smtpmail-address-buffer)
221 245
222 (smtpmail-do-bcc delimline) 246 (smtpmail-do-bcc delimline)
223 247 ; Send or queue
224 (if (not (null smtpmail-recipient-address-list)) 248 (if (not smtpmail-queue-mail)
225 (if (not (smtpmail-via-smtp smtpmail-recipient-address-list tembuf)) 249 (if (not (null smtpmail-recipient-address-list))
226 (error "Sending failed; SMTP protocol error")) 250 (if (not (smtpmail-via-smtp
227 (error "Sending failed; no recipients")) 251 smtpmail-recipient-address-list tembuf))
228 ) 252 (error "Sending failed; SMTP protocol error"))
253 (error "Sending failed; no recipients"))
254 (let* ((file-data (concat
255 smtpmail-queue-dir
256 (time-stamp-strftime
257 "%02y%02m%02d-%02H%02M%02S")))
258 (file-elisp (concat file-data ".el"))
259 (buffer-data (create-file-buffer file-data))
260 (buffer-elisp (create-file-buffer file-elisp))
261 (buffer-scratch "*queue-mail*"))
262 (save-excursion
263 (set-buffer buffer-data)
264 (erase-buffer)
265 (insert-buffer tembuf)
266 (write-file file-data)
267 (set-buffer buffer-elisp)
268 (erase-buffer)
269 (insert (concat
270 "(setq smtpmail-recipient-address-list '"
271 (prin1-to-string smtpmail-recipient-address-list)
272 ")\n"))
273 (write-file file-elisp)
274 (set-buffer (generate-new-buffer buffer-scratch))
275 (insert (concat file-data "\n"))
276 (append-to-file (point-min)
277 (point-max)
278 smtpmail-queue-index)
279 )
280 (kill-buffer buffer-scratch)
281 (kill-buffer buffer-data)
282 (kill-buffer buffer-elisp))))
229 (kill-buffer tembuf) 283 (kill-buffer tembuf)
230 (if (bufferp errbuf) 284 (if (bufferp errbuf)
231 (kill-buffer errbuf))))) 285 (kill-buffer errbuf)))))
232 286
287(defun smtpmail-send-queued-mail ()
288 "Send mail that was queued as a result of setting `smtpmail-queue-mail'."
289 (interactive)
290 ;;; Get index, get first mail, send it, get second mail, etc...
291 (let ((buffer-index (find-file-noselect smtpmail-queue-index))
292 (file-msg "")
293 (tembuf nil))
294 (save-excursion
295 (set-buffer buffer-index)
296 (beginning-of-buffer)
297 (while (not (eobp))
298 (setq file-msg (buffer-substring (point) (save-excursion
299 (end-of-line)
300 (point))))
301 (load file-msg)
302 (setq tembuf (find-file-noselect file-msg))
303 (if (not (null smtpmail-recipient-address-list))
304 (if (not (smtpmail-via-smtp smtpmail-recipient-address-list
305 tembuf))
306 (error "Sending failed; SMTP protocol error"))
307 (error "Sending failed; no recipients"))
308 (delete-file file-msg)
309 (delete-file (concat file-msg ".el"))
310 (kill-buffer tembuf)
311 (kill-line 1))
312 (set-buffer buffer-index)
313 (save-buffer smtpmail-queue-index)
314 (kill-buffer buffer-index)
315 )))
233 316
234;(defun smtpmail-via-smtp (host,port,sender,destination,smtpmail-text-buffer) 317;(defun smtpmail-via-smtp (host,port,sender,destination,smtpmail-text-buffer)
235 318