367 |
(defun smtpmail-send-queued-mail () |
(defun smtpmail-send-queued-mail () |
368 |
"Send mail that was queued as a result of setting `smtpmail-queue-mail'." |
"Send mail that was queued as a result of setting `smtpmail-queue-mail'." |
369 |
(interactive) |
(interactive) |
370 |
;;; Get index, get first mail, send it, get second mail, etc... |
(with-temp-buffer |
371 |
(let ((buffer-index (find-file-noselect smtpmail-queue-index)) |
;;; Get index, get first mail, send it, update index, get second |
372 |
(file-msg "") |
;;; mail, send it, etc... |
373 |
(tembuf nil)) |
(let ((file-msg "")) |
374 |
(with-current-buffer buffer-index |
(insert-file-contents smtpmail-queue-index) |
375 |
(beginning-of-buffer) |
(beginning-of-buffer) |
376 |
(while (not (eobp)) |
(while (not (eobp)) |
377 |
(setq file-msg (buffer-substring (point) (line-end-position))) |
(setq file-msg (buffer-substring (point) (line-end-position))) |
379 |
;; Insert the message literally: it is already encoded as per |
;; Insert the message literally: it is already encoded as per |
380 |
;; the MIME headers, and code conversions might guess the |
;; the MIME headers, and code conversions might guess the |
381 |
;; encoding wrongly. |
;; encoding wrongly. |
382 |
(setq tembuf (find-file-noselect file-msg nil t)) |
(with-temp-buffer |
383 |
(if (not (null smtpmail-recipient-address-list)) |
(let ((coding-system-for-read 'no-conversion)) |
384 |
(if (not (smtpmail-via-smtp smtpmail-recipient-address-list |
(insert-file-contents file-msg)) |
385 |
tembuf)) |
(if (not (null smtpmail-recipient-address-list)) |
386 |
(error "Sending failed; SMTP protocol error")) |
(if (not (smtpmail-via-smtp smtpmail-recipient-address-list |
387 |
(error "Sending failed; no recipients")) |
(current-buffer))) |
388 |
|
(error "Sending failed; SMTP protocol error")) |
389 |
|
(error "Sending failed; no recipients"))) |
390 |
(delete-file file-msg) |
(delete-file file-msg) |
391 |
(delete-file (concat file-msg ".el")) |
(delete-file (concat file-msg ".el")) |
392 |
(kill-buffer tembuf) |
(kill-line 1)) |
393 |
(kill-line 1)) |
(write-region (point-min) (point-max) smtpmail-queue-index)))) |
|
(set-buffer buffer-index) |
|
|
(save-buffer smtpmail-queue-index) |
|
|
(kill-buffer buffer-index) |
|
|
))) |
|
394 |
|
|
395 |
;(defun smtpmail-via-smtp (host,port,sender,destination,smtpmail-text-buffer) |
;(defun smtpmail-via-smtp (host,port,sender,destination,smtpmail-text-buffer) |
396 |
|
|