1 ;;; mail-source.el --- functions for fetching mail
3 ;; Copyright (C) 1999-2015 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news, mail
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 (require 'format-spec)
31 (autoload 'auth-source-search "auth-source")
32 (autoload 'pop3-movemail "pop3")
33 (autoload 'pop3-get-message-count "pop3")
34 (autoload 'nnheader-cancel-timer "nnheader")
36 (require 'message) ;; for `message-directory'
38 (defvar display-time-mail-function)
40 (defgroup mail-source nil
41 "The mail-fetching library."
45 ;; Define these at compile time to avoid dragging in imap always.
46 (defconst mail-source-imap-authenticators
49 (list 'const (car a)))
50 imap-authenticator-alist)))
51 (defconst mail-source-imap-streams
54 (list 'const (car a)))
57 (defcustom mail-sources '((file))
58 "Where the mail backends will look for incoming mail.
59 This variable is a list of mail source specifiers.
60 See Info node `(gnus)Mail Source Specifiers'."
63 :link '(custom-manual "(gnus)Mail Source Specifiers")
65 (const :tag "None" nil)
67 (choice :format "%[Value Menu%] %v"
69 (cons :tag "Group parameter `mail-source'"
70 (const :format "" group))
71 (cons :tag "Spool file"
72 (const :format "" file)
73 (checklist :tag "Options" :greedy t
75 (const :format "" :value :path)
77 (cons :tag "Several files in a directory"
78 (const :format "" directory)
79 (checklist :tag "Options" :greedy t
81 (const :format "" :value :path)
82 (directory :tag "Path"))
84 (const :format "" :value :suffix)
85 (string :tag "Suffix"))
87 (const :format "" :value :predicate)
88 (function :tag "Predicate"))
90 (const :format "" :value :prescript)
91 (choice :tag "Prescript"
94 (function :format "%v")))
96 (const :format "" :value :postscript)
97 (choice :tag "Postscript"
100 (function :format "%v")))
102 (const :format "" :value :plugged)
103 (boolean :tag "Plugged"))))
104 (cons :tag "POP3 server"
105 (const :format "" pop)
106 (checklist :tag "Options" :greedy t
108 (const :format "" :value :server)
109 (string :tag "Server"))
111 (const :format "" :value :port)
114 (integer :format "%v")
115 (string :format "%v")))
117 (const :format "" :value :user)
118 (string :tag "User"))
120 (const :format "" :value :password)
121 (string :tag "Password"))
123 (const :format "" :value :program)
124 (string :tag "Program"))
126 (const :format "" :value :prescript)
127 (choice :tag "Prescript"
129 (string :format "%v")
130 (function :format "%v")
131 (const :tag "None" nil)))
133 (const :format "" :value :postscript)
134 (choice :tag "Postscript"
136 (string :format "%v")
137 (function :format "%v")
138 (const :tag "None" nil)))
140 (const :format "" :value :function)
141 (function :tag "Function"))
144 :value :authentication)
145 (choice :tag "Authentication"
150 (const :format "" :value :plugged)
151 (boolean :tag "Plugged"))
153 (const :format "" :value :stream)
154 (choice :tag "Stream"
156 (const :tag "Clear" nil)
158 (const :tag "SSL/TLS" ssl)))
160 (const :format "" :value :leave)
162 %{Leave mail on server%}:\n\t\t%[Value Menu%] %v"
165 Don't leave mails" nil)
169 Leave mails for this many days" :value 14)))))
170 (cons :tag "Maildir (qmail, postfix...)"
171 (const :format "" maildir)
172 (checklist :tag "Options" :greedy t
174 (const :format "" :value :path)
175 (directory :tag "Path"))
177 (const :format "" :value :plugged)
178 (boolean :tag "Plugged"))))
179 (cons :tag "IMAP server"
180 (const :format "" imap)
181 (checklist :tag "Options" :greedy t
183 (const :format "" :value :server)
184 (string :tag "Server"))
186 (const :format "" :value :port)
191 (const :format "" :value :user)
192 (string :tag "User"))
194 (const :format "" :value :password)
195 (string :tag "Password"))
197 (const :format "" :value :stream)
198 (choice :tag "Stream"
200 ,@mail-source-imap-streams))
202 (const :format "" :value :program)
203 (string :tag "Program"))
206 :value :authenticator)
207 (choice :tag "Authenticator"
209 ,@mail-source-imap-authenticators))
211 (const :format "" :value :mailbox)
212 (string :tag "Mailbox"
215 (const :format "" :value :predicate)
216 (string :tag "Predicate"