[Exim] Exim with mysql

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Davi Arnaut
Datum:  
To: exim-users
Betreff: [Exim] Exim with mysql
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@??? for more info.
--

Just a sample configure file wich implement
mysql virtual domain with quotas, relay and
'mailing list'.

--
Content-Description:

#CREATE TABLE m_alias (
#  id int(11) NOT NULL auto_increment,
#  usuario varchar(30) NOT NULL default '',
#  dominio varchar(30) NOT NULL default '',
#  alias longtext NOT NULL,
#  PRIMARY KEY  (id)
#) TYPE=MyISAM;

#CREATE TABLE m_mlist (
#  id int(11) NOT NULL auto_increment,
#  usuario varchar(30) NOT NULL default '',
#  dominio varchar(30) NOT NULL default '',
#  alias longtext NOT NULL,
#  PRIMARY KEY  (id)
#) TYPE=MyISAM;

#CREATE TABLE m_relay (
#  usuario varchar(30) default NULL,
#  dominio varchar(30) default NULL,
#  ip varchar(20) default NULL,
#  hora datetime default NULL
#) TYPE=MyISAM;

#CREATE TABLE m_users (
#  id int(11) NOT NULL auto_increment,
#  usuario varchar(30) NOT NULL default '',
#  dominio varchar(30) NOT NULL default '',
#  senha varchar(16) NOT NULL default '',
#  quota int(11) NOT NULL default '0',
#  av enum('0','1') NOT NULL default '0',
#  sp int(2) NOT NULL default '0',
#  bkp enum('0','1') NOT NULL default '0',
#  PRIMARY KEY  (id)
#) TYPE=MyISAM;

# Davi Arnaut (davi@???)

########### INFORMACOES DO SERVIDOR

EMPRESA=XT-Mail Verdesmares.com
ADMIN=admin@HOST
SPOOL1=/server/var/mail/normal
SPOOL2=/server/var/mail/backup
HOST=verdesmares.com

########### DADOS MYSQL

MYSQL_SERVIDOR=127.0.0.1
MYSQL_PORTA=3306
MYSQL_DB=mail
MYSQL_TABELA=mail
MYSQL_CONTA=root
MYSQL_SENHA=teste

########### TABELAS MYSQL

########### MYSQL RELAY

RELAY_TEMPO=45 MINUTE
MYSQL_RELAY = SELECT ip FROM m_relay WHERE usuario="${sender_address_local_part}" and dominio="${sender_address_domain}" and ip="${sender_host_address}" AND DATE_SUB(NOW(), INTERVAL RELAY_TEMPO) < hora limit 1

########### MYSQL QUERYS

MYSQL_DOMINIO = SELECT dominio FROM m_users WHERE dominio = '${quote_mysql:$domain}' limit 1

MYSQL_USUARIO = SELECT dominio FROM m_users WHERE dominio  = '${quote_mysql:$domain}' AND usuario  = '${quote_mysql:$local_part}' limit 1

MYSQL_ALIAS = SELECT alias FROM m_alias WHERE dominio = '${quote_mysql:$domain}' AND usuario  = '${quote_mysql:$local_part}'

MYSQL_QUOTA = SELECT quota FROM m_users WHERE dominio  = '${quote_mysql:$domain}' AND usuario  = '${quote_mysql:$local_part}' limit 1

MYSQL_BACKUP = SELECT bkp FROM m_users WHERE dominio = '${quote_mysql:$domain}' AND usuario  = '${quote_mysql:$local_part}' limit 1

MYSQL_MAILIST_COND = SELECT alias FROM m_mlist WHERE dominio = '${quote_mysql:$domain}' AND usuario  = '${quote_mysql:$local_part}' AND alias = '${quote_mysql:$sender_address}'

MYSQL_MAILIST = SELECT alias FROM m_mlist WHERE dominio = '${quote_mysql:$domain}' AND usuario  = '${quote_mysql:$local_part}'

########### MYSQL SERVER

hide mysql_servers = "MYSQL_SERVIDOR::MYSQL_PORTA/MYSQL_DB/MYSQL_CONTA/MYSQL_SENHA"

########### ADICIONAIS

MSG_QUOTA = "\   To: $local_part@$domain\n\
                 Subject: Quota de e-mail excedida.\n\n\
                 Atencao ! Essa e uma menssagem automatica.\n\n\
                 A sua quota em disco para e-mail foi excedida,\n\n\
                 queira por favor apagar seus e-mails para \
                 continuar recebendo outros e-mails. is\n\
                 Qualquer duvida, entre em contato com ADMIN .\n"

bounce_message_file = /server/smtp/bounce

received_header_text = "Received: \
          ${if def:sender_rcvhost {from $sender_rcvhost\n\t}\
          {${if def:sender_ident {from $sender_ident }}\
          ${if def:sender_helo_name {(helo=$sender_helo_name)\n\t}}}}\
          by EMPRESA - Mail Exchanger\
          ${if def:received_protocol { with $received_protocol}} \
          (XT-Mail)\n\t\
          id $message_id\
          ${if def:received_for {\n\tfor $received_for}}"

######################################################################
#                    MAIN CONFIGURATION SETTINGS                     #
######################################################################

primary_hostname = HOST

smtp_banner = ESMTP <EMPRESA>

errors_copy = ADMIN

errors_reply_to = ADMIN

domainlist local_domains = mysql;MYSQL_DOMINIO
hostlist relay_from_hosts = 127.0.0.1 : net-mysql;MYSQL_RELAY

acl_smtp_rcpt = acl_check_rcpt

never_users = root

smtp_accept_max = 200

smtp_accept_queue_per_connection = 100

split_spool_directory

rfc1413_hosts = !*

rfc1413_query_timeout = 0s

deliver_drop_privilege = true

# This will thaw (i.e. unfreeze) frozen messages every 2 days
auto_thaw = 1d

# This will throw away bounces of bounces every 3 days
ignore_bounce_errors_after = 3d

# This throws away any frozen message that's been in the queue for more than 5days
timeout_frozen_after = 5d

# Handle when warning Emails are sent
delay_warning = 2h:8h:24h:48h

# size limitations
#message_size_limit = 10M

# We don't need to bounce more than 10K back to a user
return_size_limit = 10K

# Tell postmaster when a msg is freezed
freeze_tell = ADMIN

# Timeout for local_scan, a.k.a. xt-mail
local_scan_timeout = 120s

system_filter = /server/smtp/filter
message_body_visible = 5000

######################################################################
#                       ACL CONFIGURATION                            #
#         Specifies access control lists for incoming SMTP mail      #
######################################################################

begin acl

acl_check_rcpt:

  deny    local_parts   = ^.*[^A-Za-z0-9-@._\-]
      message    = Matchs the regular expression 1.

 # deny      senders    = ^.*[@%!/|] : ^\\.
    #  message    = Matchs the regular expression 2.

  accept  domains       = +local_domains
          endpass

          message       = Erro 1. Contato: ADMIN !
          verify        = recipient

  accept  hosts         = +relay_from_hosts

  deny    message       = Erro 2. Contato: ADMIN !

######################################################################
#                      ROUTERS CONFIGURATION                         #
#               Specifies how addresses are handled                  #
######################################################################

begin routers

virtual_local_user_backup:
  condition = ${lookup mysql {MYSQL_BACKUP}{$value}}
  domains = ${lookup mysql {MYSQL_USUARIO}{$value}}
  driver = accept
  transport = virtual_delivery_backup
  unseen

virtual_local_user_padrao:
  domains = ${lookup mysql {MYSQL_USUARIO}{$value}}
  driver = accept
  transport = virtual_delivery_padrao

virtual_local_alias:
  driver = redirect
  data = ${lookup mysql {MYSQL_ALIAS}{$value}}
  file_transport = address_file
  pipe_transport = address_pipe

virtual_local_maillist:
  driver = redirect
  condition = ${lookup mysql {MYSQL_MAILIST_COND}{$value}}
  data = ${lookup mysql {MYSQL_MAILIST}{$value}}
  file_transport = address_file
  pipe_transport = address_pipe

dnslookup:
  driver = dnslookup
  domains = ! +local_domains
  transport = remote_smtp
  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
  no_more

######################################################################
#                      TRANSPORTS CONFIGURATION                      #
######################################################################

begin transports

remote_smtp:
  driver = smtp

virtual_delivery_padrao:
  driver = appendfile
  directory = SPOOL1/${substr_0_1:$domain}/${substr_1_1:$domain}/\
          ${substr_2_1:$domain}/\
              ${domain}/${substr_0_1:$local_part}/${substr_1_1:$local_part}/\
          ${substr_2_1:$local_part}/${local_part}/Maildir/
  maildir_format = yes
  quota = ${lookup mysql {MYSQL_QUOTA}{$value}}
  quota_warn_threshold = 90%
  quota_is_inclusive = true
  quota_warn_message = MSG_QUOTA
  delivery_date_add
  envelope_to_add
  return_path_add
  user = mail
  group = mail
  mode = 0660
  create_directory

virtual_delivery_backup:
  driver = appendfile
  directory = SPOOL2/${substr_0_1:$domain}/${substr_1_1:$domain}/\
          ${substr_2_1:$domain}/\
              ${domain}/${substr_0_1:$local_part}/${substr_1_1:$local_part}/\
              ${substr_2_1:$local_part}/${local_part}/Maildir/
  maildir_format = yes
  delivery_date_add
  envelope_to_add
  return_path_add
  user = mail
  group = mail
  mode = 0660
  create_directory

######################################################################
#                      RETRY CONFIGURATION                           #
######################################################################

begin retry

*                      *           F,2h,15m; G,16h,1h,1.5; F,4d,6h

######################################################################
#                      REWRITE CONFIGURATION                         #
######################################################################

begin rewrite

######################################################################
#                   AUTHENTICATION CONFIGURATION                     #
######################################################################

begin authenticators
--