Function: mail-source-check-pop

mail-source-check-pop is a byte-compiled function defined in mail-source.el.gz.

Signature

(mail-source-check-pop SOURCE)

Documentation

Check whether there is new mail.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/mail-source.el.gz
(defun mail-source-check-pop (source)
  "Check whether there is new mail."
  (mail-source-bind (pop source)
    (let ((from (format "%s:%s:%s" server user port))
	  (mail-source-string (format "pop:%s@%s" user server))
	  (process-environment (if server
				   (cons (concat "MAILHOST=" server)
					 process-environment)
				 process-environment))
	  result)
      (when (eq authentication 'password)
	(setq password
	      (or password
		  (cdr (assoc from mail-source-password-cache))
		  (read-passwd
		   (format "Password for %s at %s: " user server))))
	(unless (assoc from mail-source-password-cache)
	  (push (cons from password) mail-source-password-cache)))
      (setq result
	    (cond
	     ;; No easy way to check whether mail is waiting for these.
	     (program)
	     (function)
	     ;; The default is to use pop3.el.
	     (t
	      (require 'pop3)
	      (dlet ((pop3-password password)
		     (pop3-maildrop user)
		     (pop3-mailhost server)
		     (pop3-port port)
		     (pop3-authentication-scheme
		      (if (eq authentication 'apop) 'apop 'pass)))
		(if (or debug-on-quit debug-on-error)
		    (save-excursion (pop3-get-message-count))
		  (condition-case err
		      (save-excursion (pop3-get-message-count))
		    (error
		     ;; We nix out the password in case the error
		     ;; was because of a wrong password being given.
		     (setq mail-source-password-cache
			   (delq (assoc from mail-source-password-cache)
				 mail-source-password-cache))
		     (signal (car err) (cdr err)))))))))
      (if result
	  ;; Inform display-time that we have new mail.
	  (setq mail-source-new-mail-available (> result 0))
	;; We nix out the password in case the error
	;; was because of a wrong password being given.
	(setq mail-source-password-cache
	      (delq (assoc from mail-source-password-cache)
		    mail-source-password-cache)))
      result)))