| Line 141: |
Line 141: |
| | </nowiki> | | </nowiki> |
| | http://bradthemad.org/tech/notes/exim_cheatsheet.php | | http://bradthemad.org/tech/notes/exim_cheatsheet.php |
| | + | |
| | + | === Exim Configuration === |
| | + | dpkg-reconfigure exim4-config |
| | + | |
| | + | Creates the file: /etc/exim4/update-exim4.conf.conf<br /> |
| | + | Should look like: |
| | + | |
| | + | <nowiki># /etc/exim4/update-exim4.conf.conf |
| | + | # |
| | + | # Edit this file and /etc/mailname by hand and execute update-exim4.conf |
| | + | # yourself or use 'dpkg-reconfigure exim4-config' |
| | + | # |
| | + | # Please note that this is _not_ a dpkg-conffile and that automatic changes |
| | + | # to this file might happen. The code handling this will honor your local |
| | + | # changes, so this is usually fine, but will break local schemes that mess |
| | + | # around with multiple versions of the file. |
| | + | # |
| | + | # update-exim4.conf uses this file to determine variable values to generate |
| | + | # exim configuration macros for the configuration file. |
| | + | # |
| | + | # Most settings found in here do have corresponding questions in the |
| | + | # Debconf configuration, but not all of them. |
| | + | # |
| | + | # This is a Debian specific file |
| | + | |
| | + | dc_eximconfig_configtype='internet' |
| | + | dc_other_hostnames='[YOUR DOMAIN 1];[YOUR DOMAIN 2]' |
| | + | dc_local_interfaces='127.0.0.1;[PUT YOUR SERVER's IP ADDRESS HERE]' |
| | + | dc_readhost='' |
| | + | dc_relay_domains='' |
| | + | dc_minimaldns='false' |
| | + | dc_relay_nets='' |
| | + | dc_smarthost='' |
| | + | CFILEMODE='644' |
| | + | dc_use_split_config='true' |
| | + | dc_hide_mailname='' |
| | + | dc_mailname_in_oh='true' |
| | + | dc_localdelivery='maildir_home'</nowiki> |
| | + | |
| | + | ==== Macros ==== |
| | + | ADD the following to /etc/exim4/conf.d/main/000_localmacros |
| | + | <nowiki>MAIN_LOCAL_DOMAINS = @:localhost:dsearch;/etc/exim4/virtual:${lookup mysql{SELECT fqdn AS domain FROM domains WHERE fqdn='${quote_mysql:$domain}' AND type='local' AND active=1}}</nowiki> |
| | + | |
| | + | ADD the following to /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs |
| | + | <nowiki># List of domains considered local for exim. Domains not listed here |
| | + | # need to be deliverable remotely. |
| | + | domainlist local_domains = MAIN_LOCAL_DOMAINS |
| | + | |
| | + | # MySQL because exim4 on Debian doesn't always add this: |
| | + | |
| | + | MYSQL_SERVER=127.0.0.1 |
| | + | MYSQL_DB=email_accounts |
| | + | MYSQL_USER=email |
| | + | MYSQL_PASSWORD=password |
| | + | hide mysql_servers = MYSQL_SERVER/MYSQL_DB/MYSQL_USER/MYSQL_PASSWORD</nowiki> |
| | + | |
| | + | ==== Routers ==== |
| | + | CREATE the file /etc/exim4/conf.d/router/360_exim4-config_mysqlusers |
| | + | |
| | + | <nowiki>dovecot_user: |
| | + | driver = accept |
| | + | condition = ${lookup mysql{SELECT CONCAT(mailboxes.local_part,'@',domains.fqdn) AS goto FROM domains,mailboxes WHERE \ |
| | + | mailboxes.local_part='${quote_mysql:$local_part}' AND \ |
| | + | mailboxes.active=1 AND \ |
| | + | mailboxes.domain_id=domains.id AND \ |
| | + | domains.fqdn='${quote_mysql:$domain}' AND \ |
| | + | domains.active=1}{yes}{no}} |
| | + | transport = dovecot_delivery</nowiki> |
| | + | |
| | + | Either DELETE this file, or comment-out all lines /etc/exim4/conf.d/router/400_exim4-config_system_aliases<br /> |
| | + | |
| | + | CREATE this file /etc/exim4/conf.d/router/401_exim4-config_mysql_aliases |
| | + | |
| | + | <nowiki>### router/401_exim4-config_mysql_aliases |
| | + | ################################# |
| | + | |
| | + | # ADAM: This router handles aliasing using the proprietary mysql setup |
| | + | # |
| | + | # c.f. http://alex.mamchenkov.net/2010/06/24/exim-dovecot-and-mysql/ |
| | + | # |
| | + | |
| | + | system_aliases: |
| | + | driver = redirect |
| | + | allow_fail |
| | + | allow_defer |
| | + | data = ${lookup mysql{SELECT aliases.goto AS goto FROM domains,aliases WHERE \ |
| | + | (aliases.local_part='${quote_mysql:$local_part}' OR aliases.local_part='@') AND \ |
| | + | aliases.active=1 AND \ |
| | + | aliases.domain_id=domains.id AND \ |
| | + | domains.fqdn='${quote_mysql:$domain}' AND \ |
| | + | domains.active=1}} |
| | + | </nowiki> |
| | + | |
| | + | ==== Transports ==== |
| | + | CREATE / OVERWRITE the file /etc/exim4/conf.d/transport/30_exim4-config_dovecot |
| | + | |
| | + | <nowiki>### transport/30_exim4-config_dovecot |
| | + | ################################# |
| | + | |
| | + | # |
| | + | |
| | + | dovecot_delivery: |
| | + | driver = appendfile |
| | + | maildir_format = true |
| | + | directory = /var/spool/mail/$domain/$local_part |
| | + | create_directory = true |
| | + | directory_mode = 0770 |
| | + | mode_fail_narrower = false |
| | + | message_prefix = |
| | + | message_suffix = |
| | + | delivery_date_add |
| | + | envelope_to_add |
| | + | return_path_add |
| | + | user = mail |
| | + | group = mail |
| | + | mode = 0660 |
| | + | </nowiki> |
| | + | |
| | + | ==== Auth ==== |
| | + | CREATE the file /etc/exim4/conf.d/auth/20_exim4-config_mysql-authenticator |
| | + | |
| | + | <nowiki>### AUTHENTICATIOR SECTION |
| | + | |
| | + | auth_plain: |
| | + | driver = plaintext |
| | + | public_name = PLAIN |
| | + | server_condition = ${lookup mysql{SELECT CONCAT(mailboxes.local_part,'@',domains.fqdn) FROM mailboxes,domains WHERE \ |
| | + | mailboxes.local_part=SUBSTRING_INDEX('${quote_mysql:$auth2}','@',1) AND \ |
| | + | mailboxes.password=MD5('${quote_mysql:$auth3}') AND \ |
| | + | mailboxes.active=1 AND \ |
| | + | mailboxes.domain_id=domains.id AND \ |
| | + | domains.fqdn=SUBSTRING_INDEX('${quote_mysql:$auth2}','@',-1) AND \ |
| | + | domains.active=1}{yes}{no}} |
| | + | server_prompts = : |
| | + | server_set_id = $auth2 |
| | + | |
| | + | auth_login: |
| | + | driver = plaintext |
| | + | public_name = LOGIN |
| | + | server_condition = ${lookup mysql{SELECT CONCAT(mailboxes.local_part,'@',domains.fqdn) FROM mailboxes,domains WHERE \ |
| | + | mailboxes.local_part=SUBSTRING_INDEX('${quote_mysql:$auth1}','@',1) AND \ |
| | + | mailboxes.password=MD5('${quote_mysql:$auth2}') AND \ |
| | + | mailboxes.active=1 AND \ |
| | + | mailboxes.domain_id=domains.id AND \ |
| | + | domains.fqdn=SUBSTRING_INDEX('${quote_mysql:$auth1}','@',-1) AND \ |
| | + | domains.active=1}{yes}{no}} |
| | + | server_prompts = Username:: : Password:: |
| | + | server_set_id = $auth1 |
| | + | </nowiki> |
| | | | |
| | === STARTTLS === | | === STARTTLS === |