Function: pop3-movemail
pop3-movemail is an autoloaded and byte-compiled function defined in
pop3.el.gz.
Signature
(pop3-movemail FILE)
Documentation
Transfer contents of a maildrop to the specified FILE.
Use streaming commands.
Source Code
;; Defined in /usr/src/emacs/lisp/net/pop3.el.gz
;; Locally saved UIDL data; an alist of the server, the user, and the UIDL
;; and timestamp pairs:
;; (("SERVER_A" ("USER_A1" "UIDL1" TIMESTAMP1 "UIDL2" TIMESTAMP2...)
;; ("USER_A2" "UIDL1" TIMESTAMP1 "UIDL2" TIMESTAMP2...)
;; ...)
;; ("SERVER_B" ("USER_B1" "UIDL1" TIMESTAMP1 "UIDL2" TIMESTAMP2...)
;; ("USER_B2" "UIDL1" TIMESTAMP1 "UIDL2" TIMESTAMP2...)
;; ...))
;; Where TIMESTAMP is an Emacs time value (HI LO) representing the
;; number of seconds (+ (ash HI 16) LO).
;;;###autoload
(defun pop3-movemail (file)
"Transfer contents of a maildrop to the specified FILE.
Use streaming commands."
(let ((process (pop3-open-server pop3-mailhost pop3-port))
messages total-size
pop3-uidl
pop3-uidl-saved)
(pop3-logon process)
(if pop3-leave-mail-on-server
(setq messages (pop3-uidl-stat process)
total-size (cadr messages)
messages (car messages))
(let ((size (pop3-stat process)))
(dotimes (i (car size)) (push (1+ i) messages))
(setq messages (nreverse messages)
total-size (cadr size))))
(when messages
(with-current-buffer (process-buffer process)
(pop3-send-streaming-command process "RETR" messages total-size)
(pop3-write-to-file file messages)
(unless pop3-leave-mail-on-server
(pop3-send-streaming-command process "DELE" messages nil))))
(if pop3-leave-mail-on-server
(when (prog1 (pop3-uidl-dele process) (pop3-quit process))
(pop3-uidl-save))
(pop3-quit process)
;; Remove UIDL data for the account that got not to leave mails.
(setq pop3-uidl-saved (pop3-uidl-load))
(let ((elt (assoc pop3-maildrop
(cdr (assoc pop3-mailhost pop3-uidl-saved)))))
(when elt
(setcdr elt nil)
(pop3-uidl-save))))
t))