[vhffs-dev] [2152] updated exim4 configuration example using the new mail database schema |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 2152
Author: gradator
Date: 2012-04-22 02:33:55 +0200 (Sun, 22 Apr 2012)
Log Message:
-----------
updated exim4 configuration example using the new mail database schema
Modified Paths:
--------------
trunk/vhffs-doc/config/exim4-mx1/exim4.conf
Modified: trunk/vhffs-doc/config/exim4-mx1/exim4.conf
===================================================================
--- trunk/vhffs-doc/config/exim4-mx1/exim4.conf 2012-04-15 23:11:19 UTC (rev 2151)
+++ trunk/vhffs-doc/config/exim4-mx1/exim4.conf 2012-04-22 00:33:55 UTC (rev 2152)
@@ -1,34 +1,45 @@
-hide pgsql_servers = PGHOST/PGDB/PGUSER/PGPASS
-MAIL_HOME=/data/mail/boxes
-PGSQL_LOCAL_DOMAINS = ${lookup pgsql{SELECT mx.domain FROM vhffs_mxdomain mx INNER JOIN vhffs_object o ON o.object_id=mx.object_id WHERE o.state = 6 AND domain = '${quote_pgsql:$domain}'}}
-PGSQL_VIRTUAL_LOCAL_DOMAINS = ${lookup pgsql{select vhffs_boxes.domain from vhffs_boxes, vhffs_mxdomain where local_part = '${quote_pgsql:$local_part}' and vhffs_boxes.domain = vhffs_mxdomain.domain and vhffs_mxdomain.domain = '${quote_pgsql:$domain}' and vhffs_boxes.state = 6}}
-PGSQL_VIRTUAL_LOCAL_DIR = MAIL_HOME/${lookup pgsql{select boxes_path from vhffs_mxdomain where domain = '${quote_pgsql:$domain}'}{$value}fail}/${lookup pgsql{select mbox_name from vhffs_boxes where domain = '${quote_pgsql:$domain}' and local_part = '${quote_pgsql:$local_part}'}{$value}fail}/Maildir
-PGSQL_VIRTUAL_FORWARD_DATA = ${lookup pgsql{select remote_name from vhffs_forward, vhffs_mxdomain where local_part = '${quote_pgsql:$local_part}' and vhffs_forward.domain = vhffs_mxdomain.domain and vhffs_mxdomain.domain = '${quote_pgsql:$domain}'}}
-PGSQL_ML_EXIST = ${lookup pgsql{select domain from vhffs_ml where local_part='${quote_pgsql:$local_part}' and domain='${quote_pgsql:$domain}'}}
-PGSQL_VIRTUAL_CATCHALL = ${lookup pgsql{select catchall from vhffs_mxdomain where domain = '${quote_pgsql:$domain}' and catchall != ''}}
+#hide pgsql_servers = PGHOST/PGDB/PGUSER/PGPASS
+hide pgsql_servers = 127.0.0.1/vhffs/vhffs/vhffs
+VHFFS_LOCAL_DOMAIN = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_object omx ON omx.object_id=mx.object_id WHERE mx.domain='${quote_pgsql:$domain}' AND omx.state=6}}
+VHFFS_VIRTUAL_LOCAL_ROOT = /data/mail/boxes
+VHFFS_VIRTUAL_LOCAL_DOMAIN = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_box box ON box.localpart_id=lp.localpart_id WHERE mx.domain='${quote_pgsql:$domain}' AND lp.localpart='${quote_pgsql:$local_part}' AND box.state=6}}
+VHFFS_VIRTUAL_LOCAL_DIR = VHFFS_VIRTUAL_LOCAL_ROOT/${lookup pgsql{SELECT substr(mx.domain,1,1)||'/'||substr(mx.domain,2,1)||'/'||mx.domain||'/'||substr(lp.localpart,1,1)||'/'||lp.localpart FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_box box ON box.localpart_id=lp.localpart_id WHERE mx.domain='${quote_pgsql:$domain}' AND lp.localpart='${quote_pgsql:$local_part}' AND box.state=6}{$value}fail}/Maildir
+# note: PostgreSQL >= 9.0 supports string_agg(redir.redirect,',') syntax
+VHFFS_VIRTUAL_REDIRECT_DATA = ${lookup pgsql{SELECT array_to_string(array_agg(redir.redirect),',') FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_redirect redir ON redir.localpart_id=lp.localpart_id WHERE mx.domain='${quote_pgsql:$domain}' AND lp.localpart='${quote_pgsql:$local_part}'}}
+VHFFS_ML_EXIST = ${lookup pgsql{SELECT mx.domain FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id INNER JOIN vhffs_mx_ml ml ON ml.localpart_id=lp.localpart_id INNER JOIN vhffs_object oml ON oml.object_id=ml.object_id WHERE mx.domain='${quote_pgsql:$domain}' AND lp.localpart='${quote_pgsql:$local_part}' AND oml.state=6}}
+# note: PostgreSQL >= 9.0 supports string_agg(lpbox.localpart||'^catchall^@'||mxbox.domain,',') syntax
+PGSQL_VIRTUAL_CATCHALL = ${lookup pgsql{SELECT array_to_string(array_agg(lpbox.localpart||'^catchall^@'||mxbox.domain),',') FROM vhffs_mx mx INNER JOIN vhffs_mx_catchall ca ON mx.mx_id=ca.mx_id INNER JOIN vhffs_mx_box box ON box.box_id=ca.box_id INNER JOIN vhffs_mx_localpart lpbox ON lpbox.localpart_id=box.localpart_id INNER JOIN vhffs_mx mxbox ON mxbox.mx_id=lpbox.mx_id WHERE mx.domain='${quote_pgsql:$domain}' AND box.state=6}}
#PGSQL_GET_TX_USER = ${lookup pgsql{select vhffs_user_info.mail from vhffs_user_info, vhffs_users where vhffs_users.uid=vhffs_user_info.uid and vhffs_users.username='${quote_pgsql:$local_part}' and 'vhffs.org'='${quote_pgsql:$domain}'}}
#PGSQL_VIRTUAL_LOCAL_QUOTA = ${lookup pgsql{select quota from popbox where local_part = '${quote_pgsql:$local_part}' and domaine = '${quote_pgsql:$domain}'}}
#PGSQL_VIRTUAL_LOCAL_QFILE = ${lookup pgsql{select quota_f from popbox where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}'}}
#PGSQL_VIRTUAL_LOCAL_Q_WARN = ${lookup pgsql{select quota_warn from popbox where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}'}}
#PGSQL_VIRTUAL_LOCAL_UP_QUOTA = ${lookup pgsql{update popbox set quota_f_used = '${quote_pgsql:$quota_total_fcount}', quota_used = '${quote_pgsql:$quota_total_used}' where local_part = '${quote_pgsql:$local_part}' and domain_name = '${quote_pgsql:$domain}'}}
#PGSQL_VIRTUAL_SPAMCHECK = ${lookup pgsql{select domain_name from mxdomain where mxdomain.domain_name = '${quote_pgsql:$domain}' and scan = 1}}
+##VHFFS_AUTOREPLY_DOMAINS = ${lookup pgsql{select domain from vhffs_autoreply where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}' and current_date between period_start and period_end}}
+##VHFFS_AUTOREPLY_TEXT = ${lookup pgsql{select message from vhffs_autoreply where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}'}}
+##VHFFS_AUTOREPLY_SUBJECT = ${lookup pgsql{select subject from vhffs_autoreply where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}'}}
+##VHFFS_AUTOREPLY_ONCE_HOME = /data/mail/onces
+##VHFFS_AUTOREPLY_ONCE_DIR = VHFFS_AUTOREPLY_ONCE_HOME/${lookup pgsql{SELECT boxes_path FROM vhffs_mxdomain WHERE domain = '${quote_pgsql:$domain}'}}
+##VHFFS_SPAM_STATUS = ${lookup pgsql{select nospam from vhffs_boxes where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}' union select nospam from vhffs_ml where local_part = '${quote_pgsql:$local_part}' and domain = '${quote_pgsql:$domain}'}}
LISTENGINE_HOME=/usr/lib/vhffs/listengine/
LISTENGINE_QUEUE=LISTENGINE_HOME/listengine.pl
-LISTENGINE_UID=listengine
-LISTENGINE_GID=listengine
+LISTENGINE_UID=Debian-exim
+LISTENGINE_GID=Debian-exim
+daemon_smtp_ports = 25 : 587
+
exim_path = /usr/sbin/exim4
CONFDIR = /etc/exim4
-domainlist local_domains = PGSQL_LOCAL_DOMAINS:localhost
+domainlist local_domains = VHFFS_LOCAL_DOMAIN:localhost
domainlist relay_to_domains =
-hostlist relay_from_hosts = 127.0.0.1
+hostlist relay_from_hosts = 127.0.0.1/8
-#av_scanner = clamd:192.168.3.50 7777 stream
+#av_scanner = clamd:127.0.0.1 7777 stream
qualify_domain = mx1.vhffs.org
@@ -72,6 +83,9 @@
trusted_users = Debian-exim
+#local_from_check = false
+#untrusted_set_sender = *
+
smtp_banner = "${primary_hostname} ESMTP Vhffs4 Mailer ${tod_full}"
begin acl
@@ -85,8 +99,10 @@
# {}}
acl_check_rcpt:
- accept hosts = :
+ accept hosts = :
+ accept authenticated = *
+
# deny message = sender envelope address $sender_address is locally blacklisted here. If you think this is wrong, get in touch with postmaster
# !acl = acl_whitelist_local_deny
# senders = ${if exists{CONFDIR/local_sender_blacklist}\
@@ -140,8 +156,6 @@
# warn message = X-Broken-Reverse-DNS: no host name found for IP address $sender_host_address
# !verify = reverse_host_lookup
-# accept authenticated = *
-
require message = Relay not permitted
domains = +local_domains : +relay_to_domains
@@ -177,8 +191,58 @@
accept
+
begin routers
+## With the help of http://wiki.exim.org/EximAutoReply
+#vhffs_autoreply:
+# debug_print = "R: vhffs_autoreply for $local_part@$domain, To: $h_to"
+# driver = accept
+# domains = VHFFS_AUTOREPLY_DOMAINS
+# transport = vhffs_autoreply
+## This is were we try not to be banned from the internet...
+# condition = ${if or{ \
+## and { \
+# {!match{$h_to:}{\\b$local_part@$domain\\b} } \
+## {!match{$h_cc:}{\\b$local_part@$domain\\b} } \
+## } \
+# { match {$h_precedence:} {(?i)junk|bulk|list} } \
+# { eq {$sender_address} {} } \
+# { def:header_X-Cron-Env: } \
+# { def:header_Auto-Submitted: } \
+# { def:header_List-Id: } \
+# { def:header_List-Help: } \
+# { def:header_List-Unsubscribe:} \
+# { def:header_List-Subscribe: } \
+# { def:header_List-Owner: } \
+# { def:header_List-Post: } \
+# { def:header_List-Archive: } \
+# { def:header_Autorespond: } \
+# { def:header_X-Autoresponse: } \
+# { def:header_X-Autoreply-From: } \
+# { def:header_X-eBay-MailTracker: } \
+# { def:header_X-MaxCode-Template: } \
+# { match {$h_X-Auto-Response-Suppress: } {OOF} } \
+# { match {$h_X-OS:} {HP Onboard Administrator} } \
+# { match {$h_X-MimeOLE:} {\N^Produced By phpBB2$\N} } \
+# { match {$h_Subject:} {\N^Yahoo! Auto Response$\N} } \
+# { match {$h_Subject:} {\N^ezmlm warning$\N} } \
+# { match {$h_X-FC-MachineGenerated:} {true} } \
+# { match {$message_body} {\N^Your \"cron\" job on\N} } \
+# { match {$h_Subject:} {\N^Out of Office\N} } \
+# { match {$h_Subject:} {\N^Auto-Reply:\N} } \
+# { match {$h_Subject:} {\N^Autoresponse:\N} } \
+# { match {$h_Subject:} {\N(Auto Reply)$\N} } \
+# { match {$h_Subject:} {\N(Out of Office)$\N} } \
+# { match {$h_Subject:} {\Nis out of the office.$\N} } \
+# { match {$h_From:} {\N(via the vacation program)\N } } \
+# { match {$h_X-Spam-Flag:} {\N^yes\N} } \
+# }{no}{yes} }
+## Very important, forwards the mail to next routers
+# unseen
+# no_verify
+# no_expn
+
dnslookup_relay_to_domains:
debug_print = "R: dnslookup_relay_to_domains for $local_part@$domain"
driver = dnslookup
@@ -200,17 +264,48 @@
#spamcheck_router:
# driver = accept
# no_verify
-# domains = PGSQL_VIRTUAL_SPAMCHECK
-# condition = "${if and { {!def:h_X-Spam-Flag:} {!eq {$received_protocol}{spam-scanned}}} {1}{0}}"
+# domains = VHFFS_LOCAL_DOMAIN
+# condition = "${if and { {!def:h_X-Spam-Flag:} {!eq {$received_protocol}{spam-scanned}} {!eq{VHFFS_SPAM_STATUS}{0}} {eq{$authenticated_id}{}} {!eq{$sender_host_address}{}} {!eq{$sender_host_address}{127.0.0.1}} } {1}{0}}"
# transport = spamcheck
+#
+#blackhole_spam_router:
+# debug_print ="R: blackhole spam for $local_part@$domain"
+# driver = redirect
+# no_verify
+# condition = "${if and { {def:h_X-Spam-Flag:} {eq {$received_protocol}{spam-scanned}} {eq{VHFFS_SPAM_STATUS}{2}} } {1}{0}}"
+# data = ":blackhole:"
+virtual_local_catchall:
+ driver = accept
+ local_part_suffix = ^catchall^
+ domains = VHFFS_VIRTUAL_LOCAL_DOMAIN
+ transport = virtual_local
+
+virtual_forward_and_virtual_local:
+ driver = redirect
+## Enable this to have aaa+bbb@xxxxxxxxxxx redirected
+## to aaa@xxxxxxxxxxx
+# local_part_suffix = +*
+# local_part_suffix_optional
+ condition = ${if !eq{VHFFS_VIRTUAL_LOCAL_DOMAIN}{}}
+ qualify_preserve_domain = true
+ data = VHFFS_VIRTUAL_REDIRECT_DATA
+ unseen
+
+list_post_and_virtual_local_or_virtual_forward:
+ driver = accept
+ condition = ${if or{ {!eq{VHFFS_VIRTUAL_LOCAL_DOMAIN}{}} {!eq{VHFFS_VIRTUAL_REDIRECT_DATA}{}} } }
+ domains = VHFFS_ML_EXIST
+ transport = list_post
+ unseen
+
virtual_local:
driver = accept
## Enable this to have aaa+bbb@xxxxxxxxxxx redirected
## to aaa@xxxxxxxxxxx
# local_part_suffix = +*
# local_part_suffix_optional
- domains = PGSQL_VIRTUAL_LOCAL_DOMAINS
+ domains = VHFFS_VIRTUAL_LOCAL_DOMAIN
transport = virtual_local
virtual_forward:
@@ -220,31 +315,19 @@
# local_part_suffix = +*
# local_part_suffix_optional
qualify_preserve_domain = true
- data = PGSQL_VIRTUAL_FORWARD_DATA
+ data = VHFFS_VIRTUAL_REDIRECT_DATA
-list_director:
+list_post:
driver = accept
- domains = PGSQL_ML_EXIST
- transport = list_transport
+ domains = VHFFS_ML_EXIST
+ transport = list_post
-list_sub:
+list_request:
driver = accept
local_part_suffix = -request
- condition = PGSQL_ML_EXIST
- transport = list_sub_transport
+ condition = VHFFS_ML_EXIST
+ transport = list_request
-#list_unsub:
-# driver = accept
-# local_part_suffix = -unsubscribe
-# condition = PGSQL_ML_EXIST
-# transport = list_unsub_transport
-
-#list_confirm:
-# driver = accept
-# local_part_suffix = -confirm
-# condition = PGSQL_ML_EXIST
-# transport = list_confirm_transport
-
virtual_catchall:
driver = redirect
qualify_preserve_domain = true
@@ -263,6 +346,7 @@
data = ${lookup{$local_part}lsearch{/etc/aliases}}
file_transport = address_file
+
begin transports
address_file:
@@ -315,17 +399,17 @@
driver = smtp
#spamcheck:
-# debug_print = "T: spamassassin_pipe for $local_part@$domain"
-# driver = pipe
-# command = /usr/sbin/exim4 -oMr spam-scanned -bS
-# use_bsmtp
-# transport_filter = /usr/bin/spamc -d 192.168.3.50 -p 783
-# home_directory = "/tmp"
-# current_directory = "/tmp"
-# user = Debian-exim
-# group = Debian-exim
-# return_fail_output
-# headers_remove = X-Spam-Flag : X-Spam-Status : X-Spam-Level : X-Spam-Scanned
+# debug_print = "T: spamassassin_pipe for $local_part@$domain"
+# driver = pipe
+# command = /usr/sbin/exim4 -oMr spam-scanned -bS
+# use_bsmtp
+# transport_filter = /usr/bin/spamc -d 127.0.0.1 -p 783
+# home_directory = "/tmp"
+# current_directory = "/tmp"
+# user = Debian-exim
+# group = Debian-exim
+# return_fail_output
+# headers_remove = X-Spam-Flag : X-Spam-Status : X-Spam-Level : X-Spam-Scanned
address_directory:
debug_print = "T: address_directory for $local_part@$domain"
@@ -338,7 +422,7 @@
virtual_local:
driver = appendfile
- directory = PGSQL_VIRTUAL_LOCAL_DIR
+ directory = VHFFS_VIRTUAL_LOCAL_DIR
maildir_format
user = Debian-exim
group = Debian-exim
@@ -362,60 +446,45 @@
# Cordialement\n \
# Votre gestionnaire de courier"
-list_transport:
- driver = pipe
- command = LISTENGINE_QUEUE bounce ${lc:$local_part} ${lc:$domain}
- current_directory = LISTENGINE_HOME
-# home_directory = LISTENGINE_HOME
- user = LISTENGINE_UID
+list_post:
+ driver = pipe
+ command = LISTENGINE_QUEUE bounce ${lc:$local_part} ${lc:$domain}
+ current_directory = LISTENGINE_HOME
+ home_directory = LISTENGINE_HOME
+ user = LISTENGINE_UID
+ group = LISTENGINE_GID
-#list_master_transport:
-# driver = pipe
-# command = LISTENGINE_QUEUE
-# current_directory = LISTENGINE_HOME
-# home_directory = LISTENGINE_HOME
-# user = LISTENGINE_UID
-# group = LISTENGINE_GID
-#
+list_request:
+ driver = pipe
+ command = LISTENGINE_QUEUE request ${lc:$local_part} ${lc:$domain}
+ current_directory = LISTENGINE_HOME
+ home_directory = LISTENGINE_HOME
+ user = LISTENGINE_UID
+ group = LISTENGINE_GID
-list_sub_transport:
- driver = pipe
- command = LISTENGINE_QUEUE request ${lc:$local_part} ${lc:$domain}
- current_directory = LISTENGINE_HOME
- home_directory = LISTENGINE_HOME
- user = LISTENGINE_UID
- group = LISTENGINE_GID
+#vhffs_autoreply:
+# driver = autoreply
+# # once = VHFFS_AUTOREPLY_ONCE_HOME/$local_part-$domain.once
+# once_repeat = 7d
+# # Include a copy of the original message
+# #return_message
+# # Bounce mail to sender address or to
+# # the address specified in the Errors-To header
+# from = $local_part@$domain
+# to = "${if def:h_Errors-To: {$h_Errors-To:} {$sender_address}}"
+# subject = [Autoreply] ${rfc2047:VHFFS_AUTOREPLY_SUBJECT}
+# text = VHFFS_AUTOREPLY_TEXT
+# # Avoid characters corruption
+# headers=MIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit
-#list_unsub_transport:
-# driver = pipe
-# command = LISTENGINE_QUEUE action unsubscribe ${lc:$local_part}_${lc:$domain}
-# current_directory = LISTENGINE_HOME
-# home_directory = LISTENGINE_HOME
-# user = LISTENGINE_UID
-# group = LISTENGINE_GID
-#list_info_transport:
-# driver = pipe
-# command = LISTENGINE_QUEUE action info ${lc:$local_part}_${lc:$domain}
-# current_directory = LISTENGINE_HOME
-# home_directory = LISTENGINE_HOME
-# user = LISTENGINE_UID
-# group = LISTENGINE_GID
-
-#list_confirm_transport:
-# driver = pipe
-# command = LISTENGINE_QUEUE action confirm ${lc:$local_part}_${lc:$domain}
-# current_directory = LISTENGINE_HOME
-# home_directory = LISTENGINE_HOME
-# user = LISTENGINE_UID
-# group = LISTENGINE_GID
-
begin retry
#* quota_7d
#* quota F,2h,15m; F,3d,1h
* * F,15m,15m; F,4h,1h; G,20h,1h,1.5; F,3d,12h
+
begin rewrite
#*@+local_domains ${lookup{${local_part}}lsearch{/etc/email-addresses}\
@@ -425,18 +494,22 @@
# {${lookup{${local_part}}lsearch{CONFDIR/email-addresses}\
# {$value}fail}}fail}" Ffrs
+
begin authenticators
-# plain_server:
-# driver = plaintext
-# public_name = PLAIN
-# server_condition = ${if and {{!eq{$2}{}}{!eq{$3}{}}{eq {$3} {${lookup pgsql{select password from vhffs_boxes where local_part = '${local_part:$2}' and domain = '${domain:$2}'} {$value}fail}}}}{1}{0}}
-# server_set_id = $2
-# server_prompts = :
+plain:
+ driver = plaintext
+ public_name = PLAIN
+ server_condition = ${if and{ {!eq{$auth2}{}}{!eq{$auth3}{}}{crypteq {$auth3} {\{crypt\}${lookup pgsql{SELECT lp.password FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id WHERE mx.domain='${quote_pgsql:${domain:$auth2}}' AND lp.localpart='${quote_pgsql:${local_part:$auth2}}'} {$value}fail}}}}{1}{0}}
+ server_set_id = $auth2
+ server_prompts = :
+# server_advertise_condition = ${if def:tls_cipher }
-# login_server:
-# driver = plaintext
-# public_name = LOGIN
-# server_prompts = "Username:: : Password::"
-# server_condition = ${if and {{!eq{$1}{}}{!eq{$2}{}}{eq {$2} {${lookup pgsql{select password from vhffs_boxes where local_part = '${local_part:$1}' and domain = '${domain:$1}'} {$value}fail}}}}{1}{0}}
-# server_set_id = $1
+login:
+ driver = plaintext
+ public_name = LOGIN
+ server_prompts = Username:: : Password::
+ server_condition = ${if and{ {!eq{$auth1}{}}{!eq{$auth2}{}}{crypteq {$auth2} {\{crypt\}${lookup pgsql{SELECT lp.password FROM vhffs_mx mx INNER JOIN vhffs_mx_localpart lp ON lp.mx_id=mx.mx_id WHERE mx.domain='${quote_pgsql:${domain:$auth1}}' AND lp.localpart='${quote_pgsql:${local_part:$auth1}}'} {$value}fail}}}}{1}{0}}
+ server_set_id = $auth1
+# server_advertise_condition = ${if def:tls_cipher }
+