1# Modules introduction23maddy is built of many small components called "modules". Each module does one4certain well-defined task. Modules can be connected to each other in arbitrary5ways to achieve wanted functionality. Default configuration file defines6set of modules that together implement typical email server stack.78To specify the module that should be used by another module for something, look9for configuration directives with "module reference" argument. Then10put the module name as an argument for it. Optionally, if referenced module11needs that, put additional arguments after the name. You can also put a12configuration block with additional directives specifing the module13configuration.1415Here are some examples:1617```18smtp ... {19 # Deliver messages to the 'dummy' module with the default configuration.20 deliver_to dummy2122 # Deliver messages to the 'target.smtp' module with23 # 'tcp://127.0.0.1:1125' argument as a configuration.24 deliver_to smtp tcp://127.0.0.1:11252526 # Deliver messages to the 'queue' module with the specified configuration.27 deliver_to queue {28 target ...29 max_tries 1030 }31}32```3334Additionally, module configuration can be placed in a separate named block35at the top-level and referenced by its name where it is needed.3637Here is the example:38```39storage.imapsql local_mailboxes {40 driver sqlite341 dsn all.db42}4344smtp ... {45 deliver_to &local_mailboxes46}47```4849It is recommended to use this syntax for modules that are 'expensive' to50initialize such as storage backends and authentication providers.5152For top-level configuration block definition, syntax is as follows:53```54namespace.module_name config_block_name... {55 module_configuration56}57```58If config\_block\_name is omitted, it will be the same as module\_name. Multiple59names can be specified. All names must be unique.6061Note the "storage." prefix. This is the actual module name and includes62"namespace". It is a little cheating to make more concise names and can63be omitted when you reference the module where it is used since it can64be implied (e.g. putting module reference in "check{}" likely means you want65something with "check." prefix)6667Usual module arguments can't be specified when using this syntax, however,68modules usually provide explicit directives that allow to specify the needed69values. For example 'sql sqlite3 all.db' is equivalent to70```71storage.imapsql {72 driver sqlite373 dsn all.db74}75```76