mail.scm 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
  3. ;;; Copyright © 2017, 2018 Clément Lassieur <clement@lassieur.org>
  4. ;;; Copyright © 2017 Carlo Zancanaro <carlo@zancanaro.id.au>
  5. ;;; Copyright © 2017, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
  6. ;;; Copyright © 2019 Kristofer Buffington <kristoferbuffington@gmail.com>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; 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.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. ;;;
  23. ;;; Some of the help text was taken from the default dovecot.conf files.
  24. (define-module (gnu services mail)
  25. #:use-module (gnu services)
  26. #:use-module (gnu services base)
  27. #:use-module (gnu services configuration)
  28. #:use-module (gnu services shepherd)
  29. #:use-module (gnu system pam)
  30. #:use-module (gnu system shadow)
  31. #:use-module (gnu packages mail)
  32. #:use-module (gnu packages admin)
  33. #:use-module (gnu packages tls)
  34. #:use-module (guix records)
  35. #:use-module (guix packages)
  36. #:use-module (guix gexp)
  37. #:use-module (ice-9 match)
  38. #:use-module (ice-9 format)
  39. #:use-module (srfi srfi-1)
  40. #:export (dovecot-service
  41. dovecot-service-type
  42. dovecot-configuration
  43. opaque-dovecot-configuration
  44. dict-configuration
  45. passdb-configuration
  46. userdb-configuration
  47. unix-listener-configuration
  48. fifo-listener-configuration
  49. inet-listener-configuration
  50. service-configuration
  51. protocol-configuration
  52. plugin-configuration
  53. mailbox-configuration
  54. namespace-configuration
  55. opensmtpd-configuration
  56. opensmtpd-configuration?
  57. opensmtpd-service-type
  58. %default-opensmtpd-config-file
  59. mail-aliases-service-type
  60. exim-configuration
  61. exim-configuration?
  62. exim-service-type
  63. %default-exim-config-file
  64. imap4d-configuration
  65. imap4d-configuration?
  66. imap4d-service-type
  67. %default-imap4d-config-file))
  68. ;;; Commentary:
  69. ;;;
  70. ;;; This module provides service definitions for the Dovecot POP3 and IMAP
  71. ;;; mail server.
  72. ;;;
  73. ;;; Code:
  74. (define (uglify-field-name field-name)
  75. (let ((str (symbol->string field-name)))
  76. (string-join (string-split (if (string-suffix? "?" str)
  77. (substring str 0 (1- (string-length str)))
  78. str)
  79. #\-)
  80. "_")))
  81. (define (serialize-field field-name val)
  82. (format #t "~a=~a\n" (uglify-field-name field-name) val))
  83. (define (serialize-string field-name val)
  84. (serialize-field field-name val))
  85. (define (space-separated-string-list? val)
  86. (and (list? val)
  87. (and-map (lambda (x)
  88. (and (string? x) (not (string-index x #\space))))
  89. val)))
  90. (define (serialize-space-separated-string-list field-name val)
  91. (match val
  92. (() #f)
  93. (_ (serialize-field field-name (string-join val " ")))))
  94. (define (comma-separated-string-list? val)
  95. (and (list? val)
  96. (and-map (lambda (x)
  97. (and (string? x) (not (string-index x #\,))))
  98. val)))
  99. (define (serialize-comma-separated-string-list field-name val)
  100. (serialize-field field-name (string-join val ",")))
  101. (define (file-name? val)
  102. (and (string? val)
  103. (string-prefix? "/" val)))
  104. (define (serialize-file-name field-name val)
  105. (serialize-string field-name val))
  106. (define (colon-separated-file-name-list? val)
  107. (and (list? val)
  108. ;; Trailing slashes not needed and not
  109. (and-map file-name? val)))
  110. (define (serialize-colon-separated-file-name-list field-name val)
  111. (serialize-field field-name (string-join val ":")))
  112. (define (serialize-boolean field-name val)
  113. (serialize-string field-name (if val "yes" "no")))
  114. (define (non-negative-integer? val)
  115. (and (exact-integer? val) (not (negative? val))))
  116. (define (serialize-non-negative-integer field-name val)
  117. (serialize-field field-name val))
  118. (define (hours? val) (non-negative-integer? val))
  119. (define (serialize-hours field-name val)
  120. (serialize-field field-name (format #f "~a hours" val)))
  121. (define (free-form-fields? val)
  122. (match val
  123. (() #t)
  124. ((((? symbol?) . (? string?)) . val) (free-form-fields? val))
  125. (_ #f)))
  126. (define (serialize-free-form-fields field-name val)
  127. (for-each (match-lambda ((k . v) (serialize-field k v))) val))
  128. (define (free-form-args? val)
  129. (match val
  130. (() #t)
  131. ((((? symbol?) . (? string?)) . val) (free-form-args? val))
  132. (_ #f)))
  133. (define (serialize-free-form-args field-name val)
  134. (serialize-field field-name
  135. (string-join
  136. (map (match-lambda ((k . v) (format #t "~a=~a" k v))) val)
  137. " ")))
  138. (define-configuration dict-configuration
  139. (entries
  140. (free-form-fields '())
  141. "A list of key-value pairs that this dict should hold."))
  142. (define (serialize-dict-configuration field-name val)
  143. (format #t "dict {\n")
  144. (serialize-configuration val dict-configuration-fields)
  145. (format #t "}\n"))
  146. (define-configuration passdb-configuration
  147. (driver
  148. (string "pam")
  149. "The driver that the passdb should use. Valid values include
  150. @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
  151. @samp{static}.")
  152. (args
  153. (space-separated-string-list '())
  154. "Space separated list of arguments to the passdb driver."))
  155. (define (serialize-passdb-configuration field-name val)
  156. (format #t "passdb {\n")
  157. (serialize-configuration val passdb-configuration-fields)
  158. (format #t "}\n"))
  159. (define (passdb-configuration-list? val)
  160. (and (list? val) (and-map passdb-configuration? val)))
  161. (define (serialize-passdb-configuration-list field-name val)
  162. (for-each (lambda (val) (serialize-passdb-configuration field-name val)) val))
  163. (define-configuration userdb-configuration
  164. (driver
  165. (string "passwd")
  166. "The driver that the userdb should use. Valid values include
  167. @samp{passwd} and @samp{static}.")
  168. (args
  169. (space-separated-string-list '())
  170. "Space separated list of arguments to the userdb driver.")
  171. (override-fields
  172. (free-form-args '())
  173. "Override fields from passwd."))
  174. (define (serialize-userdb-configuration field-name val)
  175. (format #t "userdb {\n")
  176. (serialize-configuration val userdb-configuration-fields)
  177. (format #t "}\n"))
  178. (define (userdb-configuration-list? val)
  179. (and (list? val) (and-map userdb-configuration? val)))
  180. (define (serialize-userdb-configuration-list field-name val)
  181. (for-each (lambda (val) (serialize-userdb-configuration field-name val)) val))
  182. (define-configuration unix-listener-configuration
  183. (path
  184. (string (configuration-missing-field 'unix-listener 'path))
  185. "Path to the file, relative to @code{base-dir} field. This is also used as
  186. the section name.")
  187. (mode
  188. (string "0600")
  189. "The access mode for the socket.")
  190. (user
  191. (string "")
  192. "The user to own the the socket.")
  193. (group
  194. (string "")
  195. "The group to own the socket."))
  196. (define (serialize-unix-listener-configuration field-name val)
  197. (format #t "unix_listener ~a {\n" (unix-listener-configuration-path val))
  198. (serialize-configuration val (cdr unix-listener-configuration-fields))
  199. (format #t "}\n"))
  200. (define-configuration fifo-listener-configuration
  201. (path
  202. (string (configuration-missing-field 'fifo-listener 'path))
  203. "Path to the file, relative to @code{base-dir} field. This is also used as
  204. the section name.")
  205. (mode
  206. (string "0600")
  207. "The access mode for the socket.")
  208. (user
  209. (string "")
  210. "The user to own the the socket.")
  211. (group
  212. (string "")
  213. "The group to own the socket."))
  214. (define (serialize-fifo-listener-configuration field-name val)
  215. (format #t "fifo_listener ~a {\n" (fifo-listener-configuration-path val))
  216. (serialize-configuration val (cdr fifo-listener-configuration-fields))
  217. (format #t "}\n"))
  218. (define-configuration inet-listener-configuration
  219. (protocol
  220. (string (configuration-missing-field 'inet-listener 'protocol))
  221. "The protocol to listen for.")
  222. (address
  223. (string "")
  224. "The address on which to listen, or empty for all addresses.")
  225. (port
  226. (non-negative-integer
  227. (configuration-missing-field 'inet-listener 'port))
  228. "The port on which to listen.")
  229. (ssl?
  230. (boolean #t)
  231. "Whether to use SSL for this service; @samp{yes}, @samp{no}, or
  232. @samp{required}."))
  233. (define (serialize-inet-listener-configuration field-name val)
  234. (format #t "inet_listener ~a {\n" (inet-listener-configuration-protocol val))
  235. (serialize-configuration val (cdr inet-listener-configuration-fields))
  236. (format #t "}\n"))
  237. (define (listener-configuration? val)
  238. (or (unix-listener-configuration? val)
  239. (fifo-listener-configuration? val)
  240. (inet-listener-configuration? val)))
  241. (define (serialize-listener-configuration field-name val)
  242. (cond
  243. ((unix-listener-configuration? val)
  244. (serialize-unix-listener-configuration field-name val))
  245. ((fifo-listener-configuration? val)
  246. (serialize-fifo-listener-configuration field-name val))
  247. ((inet-listener-configuration? val)
  248. (serialize-inet-listener-configuration field-name val))
  249. (else (configuration-field-error field-name val))))
  250. (define (listener-configuration-list? val)
  251. (and (list? val) (and-map listener-configuration? val)))
  252. (define (serialize-listener-configuration-list field-name val)
  253. (for-each (lambda (val)
  254. (serialize-listener-configuration field-name val))
  255. val))
  256. (define-configuration service-configuration
  257. (kind
  258. (string (configuration-missing-field 'service 'kind))
  259. "The service kind. Valid values include @code{director},
  260. @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
  261. @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
  262. @code{tcpwrap}, @code{quota-warning}, or anything else.")
  263. (listeners
  264. (listener-configuration-list '())
  265. "Listeners for the service. A listener is either an
  266. @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
  267. an @code{inet-listener-configuration}.")
  268. (client-limit
  269. (non-negative-integer 0)
  270. "Maximum number of simultaneous client connections per process. Once this
  271. number of connections is received, the next incoming connection will prompt
  272. Dovecot to spawn another process. If set to 0, @code{default-client-limit} is
  273. used instead.")
  274. (service-count
  275. (non-negative-integer 1)
  276. "Number of connections to handle before starting a new process.
  277. Typically the only useful values are 0 (unlimited) or 1. 1 is more
  278. secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.")
  279. (process-limit
  280. (non-negative-integer 0)
  281. "Maximum number of processes that can exist for this service. If set to 0,
  282. @code{default-process-limit} is used instead.")
  283. (process-min-avail
  284. (non-negative-integer 0)
  285. "Number of processes to always keep waiting for more connections.")
  286. ;; FIXME: Need to be able to take the default for this value from other
  287. ;; parts of the config.
  288. (vsz-limit
  289. (non-negative-integer #e256e6)
  290. "If you set @samp{service-count 0}, you probably need to grow
  291. this."))
  292. (define (serialize-service-configuration field-name val)
  293. (format #t "service ~a {\n" (service-configuration-kind val))
  294. (serialize-configuration val (cdr service-configuration-fields))
  295. (format #t "}\n"))
  296. (define (service-configuration-list? val)
  297. (and (list? val) (and-map service-configuration? val)))
  298. (define (serialize-service-configuration-list field-name val)
  299. (for-each (lambda (val)
  300. (serialize-service-configuration field-name val))
  301. val))
  302. (define-configuration protocol-configuration
  303. (name
  304. (string (configuration-missing-field 'protocol 'name))
  305. "The name of the protocol.")
  306. (auth-socket-path
  307. (string "/var/run/dovecot/auth-userdb")
  308. "UNIX socket path to master authentication server to find users.
  309. This is used by imap (for shared users) and lda.")
  310. (mail-plugins
  311. (space-separated-string-list '("$mail_plugins"))
  312. "Space separated list of plugins to load.")
  313. (mail-max-userip-connections
  314. (non-negative-integer 10)
  315. "Maximum number of IMAP connections allowed for a user from each IP
  316. address. NOTE: The username is compared case-sensitively."))
  317. (define (serialize-protocol-configuration field-name val)
  318. (format #t "protocol ~a {\n" (protocol-configuration-name val))
  319. (serialize-configuration val (cdr protocol-configuration-fields))
  320. (format #t "}\n"))
  321. (define (protocol-configuration-list? val)
  322. (and (list? val) (and-map protocol-configuration? val)))
  323. (define (serialize-protocol-configuration-list field-name val)
  324. (serialize-field 'protocols
  325. (string-join (map protocol-configuration-name val) " "))
  326. (for-each (lambda (val)
  327. (serialize-protocol-configuration field-name val))
  328. val))
  329. (define-configuration plugin-configuration
  330. (entries
  331. (free-form-fields '())
  332. "A list of key-value pairs that this dict should hold."))
  333. (define (serialize-plugin-configuration field-name val)
  334. (format #t "plugin {\n")
  335. (serialize-configuration val plugin-configuration-fields)
  336. (format #t "}\n"))
  337. (define-configuration mailbox-configuration
  338. (name
  339. (string (error "mailbox name is required"))
  340. "Name for this mailbox.")
  341. (auto
  342. (string "no")
  343. "@samp{create} will automatically create this mailbox.
  344. @samp{subscribe} will both create and subscribe to the mailbox.")
  345. (special-use
  346. (space-separated-string-list '())
  347. "List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
  348. Valid values are @code{\\All}, @code{\\Archive}, @code{\\Drafts},
  349. @code{\\Flagged}, @code{\\Junk}, @code{\\Sent}, and @code{\\Trash}."))
  350. (define (serialize-mailbox-configuration field-name val)
  351. (format #t "mailbox \"~a\" {\n" (mailbox-configuration-name val))
  352. (serialize-configuration val (cdr mailbox-configuration-fields))
  353. (format #t "}\n"))
  354. (define (mailbox-configuration-list? val)
  355. (and (list? val) (and-map mailbox-configuration? val)))
  356. (define (serialize-mailbox-configuration-list field-name val)
  357. (for-each (lambda (val)
  358. (serialize-mailbox-configuration field-name val))
  359. val))
  360. (define-configuration namespace-configuration
  361. (name
  362. (string (error "namespace name is required"))
  363. "Name for this namespace.")
  364. (type
  365. (string "private")
  366. "Namespace type: @samp{private}, @samp{shared} or @samp{public}.")
  367. (separator
  368. (string "")
  369. "Hierarchy separator to use. You should use the same separator for
  370. all namespaces or some clients get confused. @samp{/} is usually a good
  371. one. The default however depends on the underlying mail storage
  372. format.")
  373. (prefix
  374. (string "")
  375. "Prefix required to access this namespace. This needs to be
  376. different for all namespaces. For example @samp{Public/}.")
  377. (location
  378. (string "")
  379. "Physical location of the mailbox. This is in same format as
  380. mail_location, which is also the default for it.")
  381. (inbox?
  382. (boolean #f)
  383. "There can be only one INBOX, and this setting defines which
  384. namespace has it.")
  385. (hidden?
  386. (boolean #f)
  387. "If namespace is hidden, it's not advertised to clients via NAMESPACE
  388. extension. You'll most likely also want to set @samp{list? #f}. This is mostly
  389. useful when converting from another server with different namespaces
  390. which you want to deprecate but still keep working. For example you can
  391. create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
  392. and @samp{mail/}.")
  393. (list?
  394. (boolean #t)
  395. "Show the mailboxes under this namespace with LIST command. This
  396. makes the namespace visible for clients that don't support NAMESPACE
  397. extension. The special @code{children} value lists child mailboxes, but
  398. hides the namespace prefix.")
  399. (subscriptions?
  400. (boolean #t)
  401. "Namespace handles its own subscriptions. If set to @code{#f}, the
  402. parent namespace handles them. The empty prefix should always have this
  403. as @code{#t}.)")
  404. (mailboxes
  405. (mailbox-configuration-list '())
  406. "List of predefined mailboxes in this namespace."))
  407. (define (serialize-namespace-configuration field-name val)
  408. (format #t "namespace ~a {\n" (namespace-configuration-name val))
  409. (serialize-configuration val (cdr namespace-configuration-fields))
  410. (format #t "}\n"))
  411. (define (list-of-namespace-configuration? val)
  412. (and (list? val) (and-map namespace-configuration? val)))
  413. (define (serialize-list-of-namespace-configuration field-name val)
  414. (for-each (lambda (val)
  415. (serialize-namespace-configuration field-name val))
  416. val))
  417. (define-configuration dovecot-configuration
  418. (dovecot
  419. (package dovecot)
  420. "The dovecot package.")
  421. (listen
  422. (comma-separated-string-list '("*" "::"))
  423. "A list of IPs or hosts where to listen in for connections. @samp{*}
  424. listens in all IPv4 interfaces, @samp{::} listens in all IPv6
  425. interfaces. If you want to specify non-default ports or anything more
  426. complex, customize the address and port fields of the
  427. @samp{inet-listener} of the specific services you are interested in.")
  428. (dict
  429. (dict-configuration (dict-configuration))
  430. "Dict configuration, as created by the @code{dict-configuration}
  431. constructor.")
  432. (passdbs
  433. (passdb-configuration-list (list (passdb-configuration (driver "pam"))))
  434. "List of passdb configurations, each one created by the
  435. @code{passdb-configuration} constructor.")
  436. (userdbs
  437. (userdb-configuration-list (list (userdb-configuration (driver "passwd"))))
  438. "List of userdb configurations, each one created by the
  439. @code{userdb-configuration} constructor.")
  440. (plugin-configuration
  441. (plugin-configuration (plugin-configuration))
  442. "Plug-in configuration, created by the @code{plugin-configuration}
  443. constructor.")
  444. (namespaces
  445. (list-of-namespace-configuration
  446. (list
  447. (namespace-configuration
  448. (name "inbox")
  449. (prefix "")
  450. (inbox? #t)
  451. (mailboxes
  452. (list
  453. (mailbox-configuration (name "Drafts") (special-use '("\\Drafts")))
  454. (mailbox-configuration (name "Junk") (special-use '("\\Junk")))
  455. (mailbox-configuration (name "Trash") (special-use '("\\Trash")))
  456. (mailbox-configuration (name "Sent") (special-use '("\\Sent")))
  457. (mailbox-configuration (name "Sent Messages") (special-use '("\\Sent")))
  458. (mailbox-configuration (name "Drafts") (special-use '("\\Drafts"))))))))
  459. "List of namespaces. Each item in the list is created by the
  460. @code{namespace-configuration} constructor.")
  461. (base-dir
  462. (file-name "/var/run/dovecot/")
  463. "Base directory where to store runtime data.")
  464. (login-greeting
  465. (string "Dovecot ready.")
  466. "Greeting message for clients.")
  467. (login-trusted-networks
  468. (space-separated-string-list '())
  469. "List of trusted network ranges. Connections from these IPs are
  470. allowed to override their IP addresses and ports (for logging and for
  471. authentication checks). @samp{disable-plaintext-auth} is also ignored
  472. for these networks. Typically you'd specify your IMAP proxy servers
  473. here.")
  474. (login-access-sockets
  475. (space-separated-string-list '())
  476. "List of login access check sockets (e.g. tcpwrap).")
  477. (verbose-proctitle?
  478. (boolean #f)
  479. "Show more verbose process titles (in ps). Currently shows user name
  480. and IP address. Useful for seeing who are actually using the IMAP
  481. processes (e.g. shared mailboxes or if same uid is used for multiple
  482. accounts).")
  483. (shutdown-clients?
  484. (boolean #t)
  485. "Should all processes be killed when Dovecot master process shuts down.
  486. Setting this to @code{#f} means that Dovecot can be upgraded without
  487. forcing existing client connections to close (although that could also
  488. be a problem if the upgrade is e.g. because of a security fix).")
  489. (doveadm-worker-count
  490. (non-negative-integer 0)
  491. "If non-zero, run mail commands via this many connections to doveadm
  492. server, instead of running them directly in the same process.")
  493. (doveadm-socket-path
  494. (string "doveadm-server")
  495. "UNIX socket or host:port used for connecting to doveadm server.")
  496. (import-environment
  497. (space-separated-string-list '("TZ"))
  498. "List of environment variables that are preserved on Dovecot startup
  499. and passed down to all of its child processes. You can also give
  500. key=value pairs to always set specific settings.")
  501. ;;; Authentication processes
  502. (disable-plaintext-auth?
  503. (boolean #t)
  504. "Disable LOGIN command and all other plaintext authentications unless
  505. SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
  506. matches the local IP (i.e. you're connecting from the same computer),
  507. the connection is considered secure and plaintext authentication is
  508. allowed. See also ssl=required setting.")
  509. (auth-cache-size
  510. (non-negative-integer 0)
  511. "Authentication cache size (e.g. @samp{#e10e6}). 0 means it's disabled.
  512. Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
  513. for caching to be used.")
  514. (auth-cache-ttl
  515. (string "1 hour")
  516. "Time to live for cached data. After TTL expires the cached record
  517. is no longer used, *except* if the main database lookup returns internal
  518. failure. We also try to handle password changes automatically: If
  519. user's previous authentication was successful, but this one wasn't, the
  520. cache isn't used. For now this works only with plaintext
  521. authentication.")
  522. (auth-cache-negative-ttl
  523. (string "1 hour")
  524. "TTL for negative hits (user not found, password mismatch).
  525. 0 disables caching them completely.")
  526. (auth-realms
  527. (space-separated-string-list '())
  528. "List of realms for SASL authentication mechanisms that need them.
  529. You can leave it empty if you don't want to support multiple realms.
  530. Many clients simply use the first one listed here, so keep the default
  531. realm first.")
  532. (auth-default-realm
  533. (string "")
  534. "Default realm/domain to use if none was specified. This is used for
  535. both SASL realms and appending @@domain to username in plaintext
  536. logins.")
  537. (auth-username-chars
  538. (string
  539. "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@")
  540. "List of allowed characters in username. If the user-given username
  541. contains a character not listed in here, the login automatically fails.
  542. This is just an extra check to make sure user can't exploit any
  543. potential quote escaping vulnerabilities with SQL/LDAP databases. If
  544. you want to allow all characters, set this value to empty.")
  545. (auth-username-translation
  546. (string "")
  547. "Username character translations before it's looked up from
  548. databases. The value contains series of from -> to characters. For
  549. example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
  550. translated to @samp{@@}.")
  551. (auth-username-format
  552. (string "%Lu")
  553. "Username formatting before it's looked up from databases. You can
  554. use the standard variables here, e.g. %Lu would lowercase the username,
  555. %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
  556. change the @samp{@@} into @samp{-AT-}. This translation is done after
  557. @samp{auth-username-translation} changes.")
  558. (auth-master-user-separator
  559. (string "")
  560. "If you want to allow master users to log in by specifying the master
  561. username within the normal username string (i.e. not using SASL
  562. mechanism's support for it), you can specify the separator character
  563. here. The format is then <username><separator><master username>.
  564. UW-IMAP uses @samp{*} as the separator, so that could be a good
  565. choice.")
  566. (auth-anonymous-username
  567. (string "anonymous")
  568. "Username to use for users logging in with ANONYMOUS SASL
  569. mechanism.")
  570. (auth-worker-max-count
  571. (non-negative-integer 30)
  572. "Maximum number of dovecot-auth worker processes. They're used to
  573. execute blocking passdb and userdb queries (e.g. MySQL and PAM).
  574. They're automatically created and destroyed as needed.")
  575. (auth-gssapi-hostname
  576. (string "")
  577. "Host name to use in GSSAPI principal names. The default is to use
  578. the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
  579. allow all keytab entries.")
  580. (auth-krb5-keytab
  581. (string "")
  582. "Kerberos keytab to use for the GSSAPI mechanism. Will use the
  583. system default (usually /etc/krb5.keytab) if not specified. You may
  584. need to change the auth service to run as root to be able to read this
  585. file.")
  586. (auth-use-winbind?
  587. (boolean #f)
  588. "Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
  589. and @samp{ntlm-auth} helper.
  590. <doc/wiki/Authentication/Mechanisms/Winbind.txt>.")
  591. (auth-winbind-helper-path
  592. (file-name "/usr/bin/ntlm_auth")
  593. "Path for Samba's @samp{ntlm-auth} helper binary.")
  594. (auth-failure-delay
  595. (string "2 secs")
  596. "Time to delay before replying to failed authentications.")
  597. (auth-ssl-require-client-cert?
  598. (boolean #f)
  599. "Require a valid SSL client certificate or the authentication
  600. fails.")
  601. (auth-ssl-username-from-cert?
  602. (boolean #f)
  603. "Take the username from client's SSL certificate, using
  604. @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
  605. CommonName.")
  606. (auth-mechanisms
  607. (space-separated-string-list '("plain"))
  608. "List of wanted authentication mechanisms. Supported mechanisms are:
  609. @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
  610. @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
  611. @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
  612. @samp{disable-plaintext-auth} setting.")
  613. (director-servers
  614. (space-separated-string-list '())
  615. "List of IPs or hostnames to all director servers, including ourself.
  616. Ports can be specified as ip:port. The default port is the same as what
  617. director service's @samp{inet-listener} is using.")
  618. (director-mail-servers
  619. (space-separated-string-list '())
  620. "List of IPs or hostnames to all backend mail servers. Ranges are
  621. allowed too, like 10.0.0.10-10.0.0.30.")
  622. (director-user-expire
  623. (string "15 min")
  624. "How long to redirect users to a specific server after it no longer
  625. has any connections.")
  626. (director-username-hash
  627. (string "%Lu")
  628. "How the username is translated before being hashed. Useful values
  629. include %Ln if user can log in with or without @@domain, %Ld if mailboxes
  630. are shared within domain.")
  631. ;;; Log destination.
  632. (log-path
  633. (string "syslog")
  634. "Log file to use for error messages. @samp{syslog} logs to syslog,
  635. @samp{/dev/stderr} logs to stderr.")
  636. (info-log-path
  637. (string "")
  638. "Log file to use for informational messages. Defaults to
  639. @samp{log-path}.")
  640. (debug-log-path
  641. (string "")
  642. "Log file to use for debug messages. Defaults to
  643. @samp{info-log-path}.")
  644. (syslog-facility
  645. (string "mail")
  646. "Syslog facility to use if you're logging to syslog. Usually if you
  647. don't want to use @samp{mail}, you'll use local0..local7. Also other
  648. standard facilities are supported.")
  649. (auth-verbose?
  650. (boolean #f)
  651. "Log unsuccessful authentication attempts and the reasons why they
  652. failed.")
  653. (auth-verbose-passwords
  654. (string "no")
  655. "In case of password mismatches, log the attempted password. Valid
  656. values are no, plain and sha1. sha1 can be useful for detecting brute
  657. force password attempts vs. user simply trying the same password over
  658. and over again. You can also truncate the value to n chars by appending
  659. \":n\" (e.g. sha1:6).")
  660. (auth-debug?
  661. (boolean #f)
  662. "Even more verbose logging for debugging purposes. Shows for example
  663. SQL queries.")
  664. (auth-debug-passwords?
  665. (boolean #f)
  666. "In case of password mismatches, log the passwords and used scheme so
  667. the problem can be debugged. Enabling this also enables
  668. @samp{auth-debug}.")
  669. (mail-debug?
  670. (boolean #f)
  671. "Enable mail process debugging. This can help you figure out why
  672. Dovecot isn't finding your mails.")
  673. (verbose-ssl?
  674. (boolean #f)
  675. "Show protocol level SSL errors.")
  676. (log-timestamp
  677. (string "\"%b %d %H:%M:%S \"")
  678. "Prefix for each line written to log file. % codes are in
  679. strftime(3) format.")
  680. (login-log-format-elements
  681. (space-separated-string-list
  682. '("user=<%u>" "method=%m" "rip=%r" "lip=%l" "mpid=%e" "%c"))
  683. "List of elements we want to log. The elements which have a
  684. non-empty variable value are joined together to form a comma-separated
  685. string.")
  686. (login-log-format
  687. (string "%$: %s")
  688. "Login log format. %s contains @samp{login-log-format-elements}
  689. string, %$ contains the data we want to log.")
  690. (mail-log-prefix
  691. (string "\"%s(%u)<%{pid}><%{session}>: \"")
  692. "Log prefix for mail processes. See doc/wiki/Variables.txt for list
  693. of possible variables you can use.")
  694. (deliver-log-format
  695. (string "msgid=%m: %$")
  696. "Format to use for logging mail deliveries. You can use variables:
  697. @table @code
  698. @item %$
  699. Delivery status message (e.g. @samp{saved to INBOX})
  700. @item %m
  701. Message-ID
  702. @item %s
  703. Subject
  704. @item %f
  705. From address
  706. @item %p
  707. Physical size
  708. @item %w
  709. Virtual size.
  710. @end table")
  711. ;;; Mailbox locations and namespaces
  712. (mail-location
  713. (string "")
  714. "Location for users' mailboxes. The default is empty, which means
  715. that Dovecot tries to find the mailboxes automatically. This won't work
  716. if the user doesn't yet have any mail, so you should explicitly tell
  717. Dovecot the full location.
  718. If you're using mbox, giving a path to the INBOX
  719. file (e.g. /var/mail/%u) isn't enough. You'll also need to tell Dovecot
  720. where the other mailboxes are kept. This is called the \"root mail
  721. directory\", and it must be the first path given in the
  722. @samp{mail-location} setting.
  723. There are a few special variables you can use, eg.:
  724. @table @samp
  725. @item %u
  726. username
  727. @item %n
  728. user part in user@@domain, same as %u if there's no domain
  729. @item %d
  730. domain part in user@@domain, empty if there's no domain
  731. @item %h
  732. home director
  733. @end table
  734. See doc/wiki/Variables.txt for full list. Some examples:
  735. @table @samp
  736. @item maildir:~/Maildir
  737. @item mbox:~/mail:INBOX=/var/mail/%u
  738. @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
  739. @end table")
  740. (mail-uid
  741. (string "")
  742. "System user and group used to access mails. If you use multiple,
  743. userdb can override these by returning uid or gid fields. You can use
  744. either numbers or names. <doc/wiki/UserIds.txt>.")
  745. (mail-gid
  746. (string "")
  747. "")
  748. (mail-privileged-group
  749. (string "")
  750. "Group to enable temporarily for privileged operations. Currently
  751. this is used only with INBOX when either its initial creation or
  752. dotlocking fails. Typically this is set to \"mail\" to give access to
  753. /var/mail.")
  754. (mail-access-groups
  755. (string "")
  756. "Grant access to these supplementary groups for mail processes.
  757. Typically these are used to set up access to shared mailboxes. Note
  758. that it may be dangerous to set these if users can create
  759. symlinks (e.g. if \"mail\" group is set here, ln -s /var/mail ~/mail/var
  760. could allow a user to delete others' mailboxes, or ln -s
  761. /secret/shared/box ~/mail/mybox would allow reading it).")
  762. (mail-full-filesystem-access?
  763. (boolean #f)
  764. "Allow full file system access to clients. There's no access checks
  765. other than what the operating system does for the active UID/GID. It
  766. works with both maildir and mboxes, allowing you to prefix mailboxes
  767. names with e.g. /path/ or ~user/.")
  768. ;;; Mail processes
  769. (mmap-disable?
  770. (boolean #f)
  771. "Don't use mmap() at all. This is required if you store indexes to
  772. shared file systems (NFS or clustered file system).")
  773. (dotlock-use-excl?
  774. (boolean #t)
  775. "Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
  776. supports @samp{O_EXCL} since version 3, so this should be safe to use
  777. nowadays by default.")
  778. (mail-fsync
  779. (string "optimized")
  780. "When to use fsync() or fdatasync() calls:
  781. @table @code
  782. @item optimized
  783. Whenever necessary to avoid losing important data
  784. @item always
  785. Useful with e.g. NFS when write()s are delayed
  786. @item never
  787. Never use it (best performance, but crashes can lose data).
  788. @end table")
  789. (mail-nfs-storage?
  790. (boolean #f)
  791. "Mail storage exists in NFS. Set this to yes to make Dovecot flush
  792. NFS caches whenever needed. If you're using only a single mail server
  793. this isn't needed.")
  794. (mail-nfs-index?
  795. (boolean #f)
  796. "Mail index files also exist in NFS. Setting this to yes requires
  797. @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.")
  798. (lock-method
  799. (string "fcntl")
  800. "Locking method for index files. Alternatives are fcntl, flock and
  801. dotlock. Dotlocking uses some tricks which may create more disk I/O
  802. than other locking methods. NFS users: flock doesn't work, remember to
  803. change @samp{mmap-disable}.")
  804. (mail-temp-dir
  805. (file-name "/tmp")
  806. "Directory in which LDA/LMTP temporarily stores incoming mails >128
  807. kB.")
  808. (first-valid-uid
  809. (non-negative-integer 500)
  810. "Valid UID range for users. This is mostly to make sure that users can't
  811. log in as daemons or other system users. Note that denying root logins is
  812. hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
  813. is set to 0.")
  814. (last-valid-uid
  815. (non-negative-integer 0)
  816. "")
  817. (first-valid-gid
  818. (non-negative-integer 1)
  819. "Valid GID range for users. Users having non-valid GID as primary group ID
  820. aren't allowed to log in. If user belongs to supplementary groups with
  821. non-valid GIDs, those groups are not set.")
  822. (last-valid-gid
  823. (non-negative-integer 0)
  824. "")
  825. (mail-max-keyword-length
  826. (non-negative-integer 50)
  827. "Maximum allowed length for mail keyword name. It's only forced when
  828. trying to create new keywords.")
  829. (valid-chroot-dirs
  830. (colon-separated-file-name-list '())
  831. "List of directories under which chrooting is allowed for mail
  832. processes (i.e. /var/mail will allow chrooting to /var/mail/foo/bar
  833. too). This setting doesn't affect @samp{login-chroot}
  834. @samp{mail-chroot} or auth chroot settings. If this setting is empty,
  835. \"/./\" in home dirs are ignored. WARNING: Never add directories here
  836. which local users can modify, that may lead to root exploit. Usually
  837. this should be done only if you don't allow shell access for users.
  838. <doc/wiki/Chrooting.txt>.")
  839. (mail-chroot
  840. (string "")
  841. "Default chroot directory for mail processes. This can be overridden
  842. for specific users in user database by giving /./ in user's home
  843. directory (e.g. /home/./user chroots into /home). Note that usually
  844. there is no real need to do chrooting, Dovecot doesn't allow users to
  845. access files outside their mail directory anyway. If your home
  846. directories are prefixed with the chroot directory, append \"/.\" to
  847. @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.")
  848. (auth-socket-path
  849. (file-name "/var/run/dovecot/auth-userdb")
  850. "UNIX socket path to master authentication server to find users.
  851. This is used by imap (for shared users) and lda.")
  852. (mail-plugin-dir
  853. (file-name "/usr/lib/dovecot")
  854. "Directory where to look up mail plugins.")
  855. (mail-plugins
  856. (space-separated-string-list '())
  857. "List of plugins to load for all services. Plugins specific to IMAP,
  858. LDA, etc. are added to this list in their own .conf files.")
  859. (mail-cache-min-mail-count
  860. (non-negative-integer 0)
  861. "The minimum number of mails in a mailbox before updates are done to
  862. cache file. This allows optimizing Dovecot's behavior to do less disk
  863. writes at the cost of more disk reads.")
  864. (mailbox-idle-check-interval
  865. (string "30 secs")
  866. "When IDLE command is running, mailbox is checked once in a while to
  867. see if there are any new mails or other changes. This setting defines
  868. the minimum time to wait between those checks. Dovecot can also use
  869. dnotify, inotify and kqueue to find out immediately when changes
  870. occur.")
  871. (mail-save-crlf?
  872. (boolean #f)
  873. "Save mails with CR+LF instead of plain LF. This makes sending those
  874. mails take less CPU, especially with sendfile() syscall with Linux and
  875. FreeBSD. But it also creates a bit more disk I/O which may just make it
  876. slower. Also note that if other software reads the mboxes/maildirs,
  877. they may handle the extra CRs wrong and cause problems.")
  878. (maildir-stat-dirs?
  879. (boolean #f)
  880. "By default LIST command returns all entries in maildir beginning
  881. with a dot. Enabling this option makes Dovecot return only entries
  882. which are directories. This is done by stat()ing each entry, so it
  883. causes more disk I/O.
  884. (For systems setting struct @samp{dirent->d_type} this check is free
  885. and it's done always regardless of this setting).")
  886. (maildir-copy-with-hardlinks?
  887. (boolean #t)
  888. "When copying a message, do it with hard links whenever possible.
  889. This makes the performance much better, and it's unlikely to have any
  890. side effects.")
  891. (maildir-very-dirty-syncs?
  892. (boolean #f)
  893. "Assume Dovecot is the only MUA accessing Maildir: Scan cur/
  894. directory only when its mtime changes unexpectedly or when we can't find
  895. the mail otherwise.")
  896. (mbox-read-locks
  897. (space-separated-string-list '("fcntl"))
  898. "Which locking methods to use for locking mbox. There are four
  899. available:
  900. @table @code
  901. @item dotlock
  902. Create <mailbox>.lock file. This is the oldest and most NFS-safe
  903. solution. If you want to use /var/mail/ like directory, the users will
  904. need write access to that directory.
  905. @item dotlock-try
  906. Same as dotlock, but if it fails because of permissions or because there
  907. isn't enough disk space, just skip it.
  908. @item fcntl
  909. Use this if possible. Works with NFS too if lockd is used.
  910. @item flock
  911. May not exist in all systems. Doesn't work with NFS.
  912. @item lockf
  913. May not exist in all systems. Doesn't work with NFS.
  914. @end table
  915. You can use multiple locking methods; if you do the order they're declared
  916. in is important to avoid deadlocks if other MTAs/MUAs are using multiple
  917. locking methods as well. Some operating systems don't allow using some of
  918. them simultaneously.")
  919. (mbox-write-locks
  920. (space-separated-string-list '("dotlock" "fcntl"))
  921. "")
  922. (mbox-lock-timeout
  923. (string "5 mins")
  924. "Maximum time to wait for lock (all of them) before aborting.")
  925. (mbox-dotlock-change-timeout
  926. (string "2 mins")
  927. "If dotlock exists but the mailbox isn't modified in any way,
  928. override the lock file after this much time.")
  929. (mbox-dirty-syncs?
  930. (boolean #t)
  931. "When mbox changes unexpectedly we have to fully read it to find out
  932. what changed. If the mbox is large this can take a long time. Since
  933. the change is usually just a newly appended mail, it'd be faster to
  934. simply read the new mails. If this setting is enabled, Dovecot does
  935. this but still safely fallbacks to re-reading the whole mbox file
  936. whenever something in mbox isn't how it's expected to be. The only real
  937. downside to this setting is that if some other MUA changes message
  938. flags, Dovecot doesn't notice it immediately. Note that a full sync is
  939. done with SELECT, EXAMINE, EXPUNGE and CHECK commands.")
  940. (mbox-very-dirty-syncs?
  941. (boolean #f)
  942. "Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
  943. EXAMINE, EXPUNGE or CHECK commands. If this is set,
  944. @samp{mbox-dirty-syncs} is ignored.")
  945. (mbox-lazy-writes?
  946. (boolean #t)
  947. "Delay writing mbox headers until doing a full write sync (EXPUNGE
  948. and CHECK commands and when closing the mailbox). This is especially
  949. useful for POP3 where clients often delete all mails. The downside is
  950. that our changes aren't immediately visible to other MUAs.")
  951. (mbox-min-index-size
  952. (non-negative-integer 0)
  953. "If mbox size is smaller than this (e.g. 100k), don't write index
  954. files. If an index file already exists it's still read, just not
  955. updated.")
  956. (mdbox-rotate-size
  957. (non-negative-integer #e10e6)
  958. "Maximum dbox file size until it's rotated.")
  959. (mdbox-rotate-interval
  960. (string "1d")
  961. "Maximum dbox file age until it's rotated. Typically in days. Day
  962. begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
  963. disabled.")
  964. (mdbox-preallocate-space?
  965. (boolean #f)
  966. "When creating new mdbox files, immediately preallocate their size to
  967. @samp{mdbox-rotate-size}. This setting currently works only in Linux
  968. with some file systems (ext4, xfs).")
  969. (mail-attachment-dir
  970. (string "")
  971. "sdbox and mdbox support saving mail attachments to external files,
  972. which also allows single instance storage for them. Other backends
  973. don't support this for now.
  974. WARNING: This feature hasn't been tested much yet. Use at your own risk.
  975. Directory root where to store mail attachments. Disabled, if empty.")
  976. (mail-attachment-min-size
  977. (non-negative-integer #e128e3)
  978. "Attachments smaller than this aren't saved externally. It's also
  979. possible to write a plugin to disable saving specific attachments
  980. externally.")
  981. (mail-attachment-fs
  982. (string "sis posix")
  983. "File system backend to use for saving attachments:
  984. @table @code
  985. @item posix
  986. No SiS done by Dovecot (but this might help FS's own deduplication)
  987. @item sis posix
  988. SiS with immediate byte-by-byte comparison during saving
  989. @item sis-queue posix
  990. SiS with delayed comparison and deduplication.
  991. @end table")
  992. (mail-attachment-hash
  993. (string "%{sha1}")
  994. "Hash format to use in attachment filenames. You can add any text and
  995. variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
  996. @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
  997. truncated, e.g. @code{%@{sha256:80@}} returns only first 80 bits.")
  998. (default-process-limit
  999. (non-negative-integer 100)
  1000. "")
  1001. (default-client-limit
  1002. (non-negative-integer 1000)
  1003. "")
  1004. (default-vsz-limit
  1005. (non-negative-integer #e256e6)
  1006. "Default VSZ (virtual memory size) limit for service processes.
  1007. This is mainly intended to catch and kill processes that leak memory
  1008. before they eat up everything.")
  1009. (default-login-user
  1010. (string "dovenull")
  1011. "Login user is internally used by login processes. This is the most
  1012. untrusted user in Dovecot system. It shouldn't have access to anything
  1013. at all.")
  1014. (default-internal-user
  1015. (string "dovecot")
  1016. "Internal user is used by unprivileged processes. It should be
  1017. separate from login user, so that login processes can't disturb other
  1018. processes.")
  1019. (ssl?
  1020. (string "required")
  1021. "SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.")
  1022. (ssl-cert
  1023. (string "</etc/dovecot/default.pem")
  1024. "PEM encoded X.509 SSL/TLS certificate (public key).")
  1025. (ssl-key
  1026. (string "</etc/dovecot/private/default.pem")
  1027. "PEM encoded SSL/TLS private key. The key is opened before
  1028. dropping root privileges, so keep the key file unreadable by anyone but
  1029. root.")
  1030. (ssl-key-password
  1031. (string "")
  1032. "If key file is password protected, give the password here.
  1033. Alternatively give it when starting dovecot with -p parameter. Since
  1034. this file is often world-readable, you may want to place this setting
  1035. instead to a different.")
  1036. (ssl-ca
  1037. (string "")
  1038. "PEM encoded trusted certificate authority. Set this only if you
  1039. intend to use @samp{ssl-verify-client-cert? #t}. The file should
  1040. contain the CA certificate(s) followed by the matching
  1041. CRL(s). (e.g. @samp{ssl-ca </etc/ssl/certs/ca.pem}).")
  1042. (ssl-require-crl?
  1043. (boolean #t)
  1044. "Require that CRL check succeeds for client certificates.")
  1045. (ssl-verify-client-cert?
  1046. (boolean #f)
  1047. "Request client to send a certificate. If you also want to require
  1048. it, set @samp{auth-ssl-require-client-cert? #t} in auth section.")
  1049. (ssl-cert-username-field
  1050. (string "commonName")
  1051. "Which field from certificate to use for username. commonName and
  1052. x500UniqueIdentifier are the usual choices. You'll also need to set
  1053. @samp{auth-ssl-username-from-cert? #t}.")
  1054. (ssl-min-protocol
  1055. (string "TLSv1")
  1056. "Minimum SSL protocol version to accept.")
  1057. (ssl-cipher-list
  1058. (string "ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@STRENGTH")
  1059. "SSL ciphers to use.")
  1060. (ssl-crypto-device
  1061. (string "")
  1062. "SSL crypto device to use, for valid values run \"openssl engine\".")
  1063. (postmaster-address
  1064. (string "postmaster@%d")
  1065. "Address to use when sending rejection mails.
  1066. Default is postmaster@@<your domain>. %d expands to recipient domain.")
  1067. (hostname
  1068. (string "")
  1069. "Hostname to use in various parts of sent mails (e.g. in Message-Id)
  1070. and in LMTP replies. Default is the system's real hostname@@domain.")
  1071. (quota-full-tempfail?
  1072. (boolean #f)
  1073. "If user is over quota, return with temporary failure instead of
  1074. bouncing the mail.")
  1075. (sendmail-path
  1076. (file-name "/usr/sbin/sendmail")
  1077. "Binary to use for sending mails.")
  1078. (submission-host
  1079. (string "")
  1080. "If non-empty, send mails via this SMTP host[:port] instead of
  1081. sendmail.")
  1082. (rejection-subject
  1083. (string "Rejected: %s")
  1084. "Subject: header to use for rejection mails. You can use the same
  1085. variables as for @samp{rejection-reason} below.")
  1086. (rejection-reason
  1087. (string "Your message to <%t> was automatically rejected:%n%r")
  1088. "Human readable error message for rejection mails. You can use
  1089. variables:
  1090. @table @code
  1091. @item %n
  1092. CRLF
  1093. @item %r
  1094. reason
  1095. @item %s
  1096. original subject
  1097. @item %t
  1098. recipient
  1099. @end table")
  1100. (recipient-delimiter
  1101. (string "+")
  1102. "Delimiter character between local-part and detail in email
  1103. address.")
  1104. (lda-original-recipient-header
  1105. (string "")
  1106. "Header where the original recipient address (SMTP's RCPT TO:
  1107. address) is taken from if not available elsewhere. With dovecot-lda -a
  1108. parameter overrides this. A commonly used header for this is
  1109. X-Original-To.")
  1110. (lda-mailbox-autocreate?
  1111. (boolean #f)
  1112. "Should saving a mail to a nonexistent mailbox automatically create
  1113. it?.")
  1114. (lda-mailbox-autosubscribe?
  1115. (boolean #f)
  1116. "Should automatically created mailboxes be also automatically
  1117. subscribed?.")
  1118. (imap-max-line-length
  1119. (non-negative-integer #e64e3)
  1120. "Maximum IMAP command line length. Some clients generate very long
  1121. command lines with huge mailboxes, so you may need to raise this if you
  1122. get \"Too long argument\" or \"IMAP command line too large\" errors
  1123. often.")
  1124. (imap-logout-format
  1125. (string "in=%i out=%o deleted=%{deleted} expunged=%{expunged} trashed=%{trashed} hdr_count=%{fetch_hdr_count} hdr_bytes=%{fetch_hdr_bytes} body_count=%{fetch_body_count} body_bytes=%{fetch_body_bytes}")
  1126. "IMAP logout format string:
  1127. @table @code
  1128. @item %i
  1129. total number of bytes read from client
  1130. @item %o
  1131. total number of bytes sent to client.
  1132. @end table
  1133. See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.")
  1134. (imap-capability
  1135. (string "")
  1136. "Override the IMAP CAPABILITY response. If the value begins with '+',
  1137. add the given capabilities on top of the defaults (e.g. +XFOO XBAR).")
  1138. (imap-idle-notify-interval
  1139. (string "2 mins")
  1140. "How long to wait between \"OK Still here\" notifications when client
  1141. is IDLEing.")
  1142. (imap-id-send
  1143. (string "")
  1144. "ID field names and values to send to clients. Using * as the value
  1145. makes Dovecot use the default value. The following fields have default
  1146. values currently: name, version, os, os-version, support-url,
  1147. support-email.")
  1148. (imap-id-log
  1149. (string "")
  1150. "ID fields sent by client to log. * means everything.")
  1151. (imap-client-workarounds
  1152. (space-separated-string-list '())
  1153. "Workarounds for various client bugs:
  1154. @table @code
  1155. @item delay-newmail
  1156. Send EXISTS/RECENT new mail notifications only when replying to NOOP and
  1157. CHECK commands. Some clients ignore them otherwise, for example OSX
  1158. Mail (<v2.1). Outlook Express breaks more badly though, without this it
  1159. may show user \"Message no longer in server\" errors. Note that OE6
  1160. still breaks even with this workaround if synchronization is set to
  1161. \"Headers Only\".
  1162. @item tb-extra-mailbox-sep
  1163. Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
  1164. adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
  1165. ignore the extra @samp{/} instead of treating it as invalid mailbox name.
  1166. @item tb-lsub-flags
  1167. Show \\Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox).
  1168. This makes Thunderbird realize they aren't selectable and show them
  1169. greyed out, instead of only later giving \"not selectable\" popup error.
  1170. @end table
  1171. ")
  1172. (imap-urlauth-host
  1173. (string "")
  1174. "Host allowed in URLAUTH URLs sent by client. \"*\" allows all.")
  1175. (protocols
  1176. (protocol-configuration-list
  1177. (list (protocol-configuration
  1178. (name "imap"))))
  1179. "List of protocols we want to serve. Available protocols include
  1180. @samp{imap}, @samp{pop3}, and @samp{lmtp}.")
  1181. (services
  1182. (service-configuration-list
  1183. (list
  1184. (service-configuration
  1185. (kind "imap-login")
  1186. (client-limit 0)
  1187. (process-limit 0)
  1188. (listeners
  1189. (list
  1190. (inet-listener-configuration (protocol "imap") (port 143) (ssl? #f))
  1191. (inet-listener-configuration (protocol "imaps") (port 993) (ssl? #t)))))
  1192. (service-configuration
  1193. (kind "pop3-login")
  1194. (listeners
  1195. (list
  1196. (inet-listener-configuration (protocol "pop3") (port 110) (ssl? #f))
  1197. (inet-listener-configuration (protocol "pop3s") (port 995) (ssl? #t)))))
  1198. (service-configuration
  1199. (kind "lmtp")
  1200. (client-limit 1)
  1201. (process-limit 0)
  1202. (listeners
  1203. (list (unix-listener-configuration (path "lmtp") (mode "0666")))))
  1204. (service-configuration
  1205. (kind "imap")
  1206. (client-limit 1)
  1207. (process-limit 1024))
  1208. (service-configuration
  1209. (kind "pop3")
  1210. (client-limit 1)
  1211. (process-limit 1024))
  1212. (service-configuration
  1213. (kind "auth")
  1214. (service-count 0)
  1215. (client-limit 0)
  1216. (process-limit 1)
  1217. (listeners
  1218. (list (unix-listener-configuration (path "auth-userdb")))))
  1219. (service-configuration
  1220. (kind "auth-worker")
  1221. (client-limit 1)
  1222. (process-limit 0))
  1223. (service-configuration
  1224. (kind "dict")
  1225. (client-limit 1)
  1226. (process-limit 0)
  1227. (listeners (list (unix-listener-configuration (path "dict")))))))
  1228. "List of services to enable. Available services include @samp{imap},
  1229. @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
  1230. @samp{lmtp}."))
  1231. (define-configuration opaque-dovecot-configuration
  1232. (dovecot
  1233. (package dovecot)
  1234. "The dovecot package.")
  1235. (string
  1236. (string (configuration-missing-field 'opaque-dovecot-configuration
  1237. 'string))
  1238. "The contents of the @code{dovecot.conf} to use."))
  1239. (define %dovecot-accounts
  1240. ;; Account and group for the Dovecot daemon.
  1241. (list (user-group (name "dovecot") (system? #t))
  1242. (user-account
  1243. (name "dovecot")
  1244. (group "dovecot")
  1245. (system? #t)
  1246. (comment "Dovecot daemon user")
  1247. (home-directory "/var/empty")
  1248. (shell (file-append shadow "/sbin/nologin")))
  1249. (user-group (name "dovenull") (system? #t))
  1250. (user-account
  1251. (name "dovenull")
  1252. (group "dovenull")
  1253. (system? #t)
  1254. (comment "Dovecot daemon login user")
  1255. (home-directory "/var/empty")
  1256. (shell (file-append shadow "/sbin/nologin")))))
  1257. (define (%dovecot-activation config)
  1258. ;; Activation gexp.
  1259. (let ((config-str
  1260. (cond
  1261. ((opaque-dovecot-configuration? config)
  1262. (opaque-dovecot-configuration-string config))
  1263. (else
  1264. (with-output-to-string
  1265. (lambda ()
  1266. (serialize-configuration config
  1267. dovecot-configuration-fields)))))))
  1268. #~(begin
  1269. (use-modules (guix build utils))
  1270. (define (mkdir-p/perms directory owner perms)
  1271. (mkdir-p directory)
  1272. (chown "/var/run/dovecot" (passwd:uid owner) (passwd:gid owner))
  1273. (chmod directory perms))
  1274. (define (build-subject parameters)
  1275. (string-concatenate
  1276. (map (lambda (pair)
  1277. (let ((k (car pair)) (v (cdr pair)))
  1278. (define (escape-char str chr)
  1279. (string-join (string-split str chr) (string #\\ chr)))
  1280. (string-append "/" k "="
  1281. (escape-char (escape-char v #\=) #\/))))
  1282. (filter (lambda (pair) (cdr pair)) parameters))))
  1283. (define* (create-self-signed-certificate-if-absent
  1284. #:key private-key public-key (owner (getpwnam "root"))
  1285. (common-name (gethostname))
  1286. (organization-name "Guix")
  1287. (organization-unit-name "Default Self-Signed Certificate")
  1288. (subject-parameters `(("CN" . ,common-name)
  1289. ("O" . ,organization-name)
  1290. ("OU" . ,organization-unit-name)))
  1291. (subject (build-subject subject-parameters)))
  1292. ;; Note that by default, OpenSSL outputs keys in PEM format. This
  1293. ;; is what we want.
  1294. (unless (file-exists? private-key)
  1295. (cond
  1296. ((zero? (system* (string-append #$openssl "/bin/openssl")
  1297. "genrsa" "-out" private-key "2048"))
  1298. (chown private-key (passwd:uid owner) (passwd:gid owner))
  1299. (chmod private-key #o400))
  1300. (else
  1301. (format (current-error-port)
  1302. "Failed to create private key at ~a.\n" private-key))))
  1303. (unless (file-exists? public-key)
  1304. (cond
  1305. ((zero? (system* (string-append #$openssl "/bin/openssl")
  1306. "req" "-new" "-x509" "-key" private-key
  1307. "-out" public-key "-days" "3650"
  1308. "-batch" "-subj" subject))
  1309. (chown public-key (passwd:uid owner) (passwd:gid owner))
  1310. (chmod public-key #o444))
  1311. (else
  1312. (format (current-error-port)
  1313. "Failed to create public key at ~a.\n" public-key)))))
  1314. (let ((user (getpwnam "dovecot")))
  1315. (mkdir-p/perms "/var/run/dovecot" user #o755)
  1316. (mkdir-p/perms "/var/lib/dovecot" user #o755)
  1317. (mkdir-p/perms "/etc/dovecot" user #o755)
  1318. (copy-file #$(plain-file "dovecot.conf" config-str)
  1319. "/etc/dovecot/dovecot.conf")
  1320. (mkdir-p/perms "/etc/dovecot/private" user #o700)
  1321. (create-self-signed-certificate-if-absent
  1322. #:private-key "/etc/dovecot/private/default.pem"
  1323. #:public-key "/etc/dovecot/default.pem"
  1324. #:owner (getpwnam "root")
  1325. #:common-name (format #f "Dovecot service on ~a" (gethostname)))))))
  1326. (define (dovecot-shepherd-service config)
  1327. "Return a list of <shepherd-service> for CONFIG."
  1328. (let ((dovecot (if (opaque-dovecot-configuration? config)
  1329. (opaque-dovecot-configuration-dovecot config)
  1330. (dovecot-configuration-dovecot config))))
  1331. (list (shepherd-service
  1332. (documentation "Run the Dovecot POP3/IMAP mail server.")
  1333. (provision '(dovecot))
  1334. (requirement '(networking))
  1335. (start #~(make-forkexec-constructor
  1336. (list (string-append #$dovecot "/sbin/dovecot")
  1337. "-F")))
  1338. (stop #~(lambda _
  1339. (invoke #$(file-append dovecot "/sbin/dovecot")
  1340. "stop")
  1341. #f))))))
  1342. (define %dovecot-pam-services
  1343. (list (unix-pam-service "dovecot")))
  1344. (define dovecot-service-type
  1345. (service-type (name 'dovecot)
  1346. (extensions
  1347. (list (service-extension shepherd-root-service-type
  1348. dovecot-shepherd-service)
  1349. (service-extension account-service-type
  1350. (const %dovecot-accounts))
  1351. (service-extension pam-root-service-type
  1352. (const %dovecot-pam-services))
  1353. (service-extension activation-service-type
  1354. %dovecot-activation)))))
  1355. (define* (dovecot-service #:key (config (dovecot-configuration)))
  1356. "Return a service that runs @command{dovecot}, a mail server that can run
  1357. POP3, IMAP, and LMTP. @var{config} should be a configuration object created
  1358. by @code{dovecot-configuration}. @var{config} may also be created by
  1359. @code{opaque-dovecot-configuration}, which allows specification of the
  1360. @code{dovecot.conf} as a string."
  1361. (validate-configuration config
  1362. (if (opaque-dovecot-configuration? config)
  1363. opaque-dovecot-configuration-fields
  1364. dovecot-configuration-fields))
  1365. (service dovecot-service-type config))
  1366. ;; A little helper to make it easier to document all those fields.
  1367. (define (generate-dovecot-documentation)
  1368. (generate-documentation
  1369. `((dovecot-configuration
  1370. ,dovecot-configuration-fields
  1371. (dict dict-configuration)
  1372. (namespaces namespace-configuration)
  1373. (plugin plugin-configuration)
  1374. (passdbs passdb-configuration)
  1375. (userdbs userdb-configuration)
  1376. (services service-configuration)
  1377. (protocols protocol-configuration))
  1378. (dict-configuration ,dict-configuration-fields)
  1379. (plugin-configuration ,plugin-configuration-fields)
  1380. (passdb-configuration ,passdb-configuration-fields)
  1381. (userdb-configuration ,userdb-configuration-fields)
  1382. (unix-listener-configuration ,unix-listener-configuration-fields)
  1383. (fifo-listener-configuration ,fifo-listener-configuration-fields)
  1384. (inet-listener-configuration ,inet-listener-configuration-fields)
  1385. (namespace-configuration
  1386. ,namespace-configuration-fields
  1387. (mailboxes mailbox-configuration))
  1388. (mailbox-configuration ,mailbox-configuration-fields)
  1389. (service-configuration
  1390. ,service-configuration-fields
  1391. (listeners unix-listener-configuration fifo-listener-configuration
  1392. inet-listener-configuration))
  1393. (protocol-configuration ,protocol-configuration-fields))
  1394. 'dovecot-configuration))
  1395. ;;;
  1396. ;;; OpenSMTPD.
  1397. ;;;
  1398. (define-record-type* <opensmtpd-configuration>
  1399. opensmtpd-configuration make-opensmtpd-configuration
  1400. opensmtpd-configuration?
  1401. (package opensmtpd-configuration-package
  1402. (default opensmtpd))
  1403. (config-file opensmtpd-configuration-config-file
  1404. (default %default-opensmtpd-config-file)))
  1405. (define %default-opensmtpd-config-file
  1406. (plain-file "smtpd.conf" "
  1407. listen on lo
  1408. action inbound mbox
  1409. match for local action inbound
  1410. action outbound relay
  1411. match from local for any action outbound
  1412. "))
  1413. (define opensmtpd-shepherd-service
  1414. (match-lambda
  1415. (($ <opensmtpd-configuration> package config-file)
  1416. (list (shepherd-service
  1417. (provision '(smtpd))
  1418. (requirement '(loopback))
  1419. (documentation "Run the OpenSMTPD daemon.")
  1420. (start (let ((smtpd (file-append package "/sbin/smtpd")))
  1421. #~(make-forkexec-constructor
  1422. (list #$smtpd "-f" #$config-file)
  1423. #:pid-file "/var/run/smtpd.pid")))
  1424. (stop #~(make-kill-destructor)))))))
  1425. (define %opensmtpd-accounts
  1426. (list (user-group
  1427. (name "smtpq")
  1428. (system? #t))
  1429. (user-account
  1430. (name "smtpd")
  1431. (group "nogroup")
  1432. (system? #t)
  1433. (comment "SMTP Daemon")
  1434. (home-directory "/var/empty")
  1435. (shell (file-append shadow "/sbin/nologin")))
  1436. (user-account
  1437. (name "smtpq")
  1438. (group "smtpq")
  1439. (system? #t)
  1440. (comment "SMTPD Queue")
  1441. (home-directory "/var/empty")
  1442. (shell (file-append shadow "/sbin/nologin")))))
  1443. (define opensmtpd-activation
  1444. (match-lambda
  1445. (($ <opensmtpd-configuration> package config-file)
  1446. (let ((smtpd (file-append package "/sbin/smtpd")))
  1447. #~(begin
  1448. (use-modules (guix build utils))
  1449. ;; Create mbox and spool directories.
  1450. (mkdir-p "/var/mail")
  1451. (mkdir-p "/var/spool/smtpd")
  1452. (chmod "/var/spool/smtpd" #o711)
  1453. (mkdir-p "/var/spool/mail")
  1454. (chmod "/var/spool/mail" #o711))))))
  1455. (define %opensmtpd-pam-services
  1456. (list (unix-pam-service "smtpd")))
  1457. (define opensmtpd-service-type
  1458. (service-type
  1459. (name 'opensmtpd)
  1460. (extensions
  1461. (list (service-extension account-service-type
  1462. (const %opensmtpd-accounts))
  1463. (service-extension activation-service-type
  1464. opensmtpd-activation)
  1465. (service-extension pam-root-service-type
  1466. (const %opensmtpd-pam-services))
  1467. (service-extension profile-service-type
  1468. (compose list opensmtpd-configuration-package))
  1469. (service-extension shepherd-root-service-type
  1470. opensmtpd-shepherd-service)))))
  1471. ;;;
  1472. ;;; mail aliases.
  1473. ;;;
  1474. (define (mail-aliases-etc aliases)
  1475. `(("aliases" ,(plain-file "aliases"
  1476. ;; Ideally we'd use a format string like
  1477. ;; "~:{~a: ~{~a~^,~}\n~}", but it gives a
  1478. ;; warning that I can't figure out how to fix,
  1479. ;; so we'll just use string-join below instead.
  1480. (format #f "~:{~a: ~a\n~}"
  1481. (map (match-lambda
  1482. ((alias addresses ...)
  1483. (list alias (string-join addresses ","))))
  1484. aliases))))))
  1485. (define mail-aliases-service-type
  1486. (service-type
  1487. (name 'mail-aliases)
  1488. (extensions
  1489. (list (service-extension etc-service-type mail-aliases-etc)))
  1490. (compose concatenate)
  1491. (extend append)))
  1492. ;;;
  1493. ;;; Exim.
  1494. ;;;
  1495. (define-record-type* <exim-configuration> exim-configuration
  1496. make-exim-configuration
  1497. exim-configuration?
  1498. (package exim-configuration-package ;<package>
  1499. (default exim))
  1500. (config-file exim-configuration-config-file ;file-like
  1501. (default #f)))
  1502. (define %exim-accounts
  1503. (list (user-group
  1504. (name "exim")
  1505. (system? #t))
  1506. (user-account
  1507. (name "exim")
  1508. (group "exim")
  1509. (system? #t)
  1510. (comment "Exim Daemon")
  1511. (home-directory "/var/empty")
  1512. (shell (file-append shadow "/sbin/nologin")))))
  1513. (define (exim-computed-config-file package config-file)
  1514. (computed-file "exim.conf"
  1515. #~(call-with-output-file #$output
  1516. (lambda (port)
  1517. (format port "
  1518. exim_user = exim
  1519. exim_group = exim
  1520. .include ~a"
  1521. #$(or config-file
  1522. (file-append package "/etc/exim.conf")))))))
  1523. (define exim-shepherd-service
  1524. (match-lambda
  1525. (($ <exim-configuration> package config-file)
  1526. (list (shepherd-service
  1527. (provision '(exim mta))
  1528. (documentation "Run the exim daemon.")
  1529. (requirement '(networking))
  1530. (start #~(make-forkexec-constructor
  1531. '(#$(file-append package "/bin/exim")
  1532. "-bd" "-v" "-C"
  1533. #$(exim-computed-config-file package config-file))))
  1534. (stop #~(make-kill-destructor)))))))
  1535. (define exim-activation
  1536. (match-lambda
  1537. (($ <exim-configuration> package config-file)
  1538. (with-imported-modules '((guix build utils))
  1539. #~(begin
  1540. (use-modules (guix build utils))
  1541. (let ((uid (passwd:uid (getpw "exim")))
  1542. (gid (group:gid (getgr "exim"))))
  1543. (mkdir-p "/var/spool/exim")
  1544. (chown "/var/spool/exim" uid gid))
  1545. (zero? (system* #$(file-append package "/bin/exim")
  1546. "-bV" "-C" #$(exim-computed-config-file package config-file))))))))
  1547. (define exim-profile
  1548. (compose list exim-configuration-package))
  1549. (define exim-service-type
  1550. (service-type
  1551. (name 'exim)
  1552. (extensions
  1553. (list (service-extension shepherd-root-service-type exim-shepherd-service)
  1554. (service-extension account-service-type (const %exim-accounts))
  1555. (service-extension activation-service-type exim-activation)
  1556. (service-extension profile-service-type exim-profile)
  1557. (service-extension mail-aliases-service-type (const '()))))))
  1558. ;;;
  1559. ;;; GNU Mailutils IMAP4 Daemon.
  1560. ;;;
  1561. (define %default-imap4d-config-file
  1562. (plain-file "imap4d.conf" "server localhost {};\n"))
  1563. (define-record-type* <imap4d-configuration>
  1564. imap4d-configuration make-imap4d-configuration imap4d-configuration?
  1565. (package imap4d-configuration-package
  1566. (default mailutils))
  1567. (config-file imap4d-configuration-config-file
  1568. (default %default-imap4d-config-file)))
  1569. (define imap4d-shepherd-service
  1570. (match-lambda
  1571. (($ <imap4d-configuration> package config-file)
  1572. (list (shepherd-service
  1573. (provision '(imap4d))
  1574. (requirement '(networking syslogd))
  1575. (documentation "Run the imap4d daemon.")
  1576. (start (let ((imap4d (file-append package "/sbin/imap4d")))
  1577. #~(make-forkexec-constructor
  1578. (list #$imap4d "--daemon" "--foreground"
  1579. "--config-file" #$config-file))))
  1580. (stop #~(make-kill-destructor)))))))
  1581. (define imap4d-service-type
  1582. (service-type
  1583. (name 'imap4d)
  1584. (description
  1585. "Run the GNU @command{imap4d} to serve e-mail messages through IMAP.")
  1586. (extensions
  1587. (list (service-extension
  1588. shepherd-root-service-type imap4d-shepherd-service)))
  1589. (default-value (imap4d-configuration))))