;; Author: Richard L. Pieri <ratinox@peorth.gweep.net>
;; Keywords: mail, pop3
-;; Version: 1.2
+;; Version: 1.3e
;; This file is part of GNU Emacs.
(require 'mail-utils)
(provide 'pop3)
+(defconst pop3-version "1.3c")
+
(defvar pop3-maildrop (or user-login-name (getenv "LOGNAME") (getenv "USER") nil)
"*POP3 maildrop.")
(defvar pop3-mailhost (or (getenv "MAILHOST") nil)
"*Password to use when connecting to POP server.")
(defvar pop3-authentication-scheme 'pass
- "*POP3 authentication scheme. Defaults to 'pass, for the standard
-USER/PASS authentication. Other valid values are 'apop.")
+ "*POP3 authentication scheme.
+Defaults to 'pass, for the standard USER/PASS authentication. Other valid
+values are 'apop.")
(defvar pop3-timestamp nil
"Timestamp returned when initially connected to the POP server.
(while (<= n message-count)
(message (format "Retrieving message %d of %d from %s..."
n message-count pop3-mailhost))
- (sit-for 0)
(pop3-retr process n crashbuf)
(save-excursion
(set-buffer crashbuf)
- (append-to-file (point-min) (point-max) crashbox))
+ (append-to-file (point-min) (point-max) crashbox)
+ (set-buffer (process-buffer process))
+ (while (> (buffer-size) 5000)
+ (goto-char (point-min))
+ (forward-line 50)
+ (delete-region (point-min) (point))))
(pop3-dele process n)
- (setq n (+ 1 n)))
+ (setq n (+ 1 n))
+ (if pop3-debug (sit-for 1) (sit-for 0.1))
+ )
(pop3-quit process)
(kill-buffer crashbuf)
)
- (sit-for 0)
)
(defun pop3-open-server (mailhost port)
(set-buffer (process-buffer process))
(goto-char pop3-read-point)
(while (not (search-forward "\r\n" nil t))
- (accept-process-output process)
+ (accept-process-output process 3)
(goto-char pop3-read-point))
(setq match-end (point))
(goto-char pop3-read-point)
(nth 1 date) (nth 0 date)
(nth 3 date) (nth 2 date)))
))
- (setq From_ (format "From %s %s\n" from date))
+ (setq From_ (format "\nFrom %s %s\n" from date))
(while (string-match "," From_)
(setq From_ (concat (substring From_ 0 (match-beginning 0))
(substring From_ (match-end 0)))))
;; TRANSACTION STATE
(defun pop3-stat (process)
- "Return a list of the number of messages in the maildrop and the size
-of the maildrop."
+ "Return the number of messages in the maildrop and the maildrop's size."
(pop3-send-command process "STAT")
(let ((response (pop3-read-response process t)))
(list (string-to-int (nth 1 (pop3-string-to-list response)))
This function currently does nothing.")
(defun pop3-retr (process msg crashbuf)
- "Retrieve message-id MSG from the server and place the contents in
-buffer CRASHBUF."
+ "Retrieve message-id MSG to buffer CRASHBUF."
(pop3-send-command process (format "RETR %s" msg))
(pop3-read-response process)
(let ((start pop3-read-point) end)
(save-excursion
(set-buffer (process-buffer process))
(while (not (re-search-forward "^\\.\r\n" nil t))
- (accept-process-output process)
+ (accept-process-output process 3)
+ ;; bill@att.com ... to save wear and tear on the heap
+ (if (> (buffer-size) 20000) (sleep-for 1))
+ (if (> (buffer-size) 50000) (sleep-for 1))
+ (if (> (buffer-size) 100000) (sleep-for 1))
+ (if (> (buffer-size) 200000) (sleep-for 1))
+ (if (> (buffer-size) 500000) (sleep-for 1))
+ ;; bill@att.com
(goto-char start))
(setq pop3-read-point (point-marker))
+;; this code does not seem to work for some POP servers...
+;; and I cannot figure out why not.
+; (goto-char (match-beginning 0))
+; (backward-char 2)
+; (if (not (looking-at "\r\n"))
+; (insert "\r\n"))
+; (re-search-forward "\\.\r\n")
(goto-char (match-beginning 0))
(setq end (point-marker))
(pop3-clean-region start end)
;; UPDATE
(defun pop3-quit (process)
- "Tell server to remove all messages marked as deleted, unlock the
-maildrop, and close the connection."
+ "Close connection to POP3 server.
+Tell server to remove all messages marked as deleted, unlock the maildrop,
+and close the connection."
(pop3-send-command process "QUIT")
(pop3-read-response process t)
(if process