2016-05-19 06:51:20 -05:00
<!DOCTYPE html>
2015-07-08 10:53:40 -05:00
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" / >
2015-07-08 11:05:13 -05:00
< title > Explanation of Amavisd SQL database< / title >
2015-07-31 23:14:52 -05:00
< link rel = "stylesheet" type = "text/css" href = "./css/markdown.css" / >
2015-07-08 10:53:40 -05:00
< / head >
< body >
< div id = "navigation" >
2016-04-19 12:48:51 -05:00
< a href = "/index.html" target = "_blank" >
< img alt = "iRedMail web site"
src="./images/logo-iredmail.png"
style="vertical-align: middle; height: 30px;"
/>
< span > iRedMail< / span >
< / a >
2016-02-29 02:15:19 -06:00
// < a href = "./index.html" > Document Index< / a > < / div > < h1 id = "explanation-of-amavisd-sql-database" > Explanation of Amavisd SQL database< / h1 >
2015-07-08 10:53:40 -05:00
< div class = "toc" >
< ul >
2015-07-08 11:05:13 -05:00
< li > < a href = "#explanation-of-amavisd-sql-database" > Explanation of Amavisd SQL database< / a > < ul >
2015-07-08 10:53:40 -05:00
< li > < a href = "#summary" > Summary< / a > < / li >
< li > < a href = "#details" > Details< / a > < ul >
< li > < a href = "#lookup_sql_dsn" > @lookup_sql_dsn< / a > < / li >
2015-07-08 11:25:14 -05:00
< li > < a href = "#todo-storage_sql_dsn" > TODO: @storage_sql_dsn< / a > < / li >
2015-07-08 10:53:40 -05:00
< / ul >
< / li >
< / ul >
< / li >
< / ul >
< / div >
< h2 id = "summary" > Summary< / h2 >
< p > Amavisd has two settings to use its SQL tables:< / p >
< ul >
< li >
2016-03-09 20:43:55 -06:00
< p > < code > @storage_sql_dsn< / code > uses 4 sql tables (< code > msgs< / code > , < code > msgrcpt< / code > , < code > maddr< / code > ,
< code > quarantine< / code > ), and it's used to store:< / p >
2015-07-08 10:53:40 -05:00
< ul >
< li > basic info of inbound and outbound message. e.g. mail subject,
sender address, recipient address, timestamp, etc. Note: no mail body.< / li >
< li > quarantined mails. Note: it stores full message of quarantined mail,
including mail body.< / li >
< / ul >
< / li >
< li >
2016-03-09 20:43:55 -06:00
< p > < code > @lookup_sql_dsn< / code > : uses 4 sql tables (< code > mailaddr< / code > , < code > policy< / code > , < code > users< / code > ,
< code > wblist< / code > ), and it's used to store:< / p >
2015-07-08 10:53:40 -05:00
< ul >
< li > per-account spam policy< / li >
< li > per-account white/blacklists< / li >
< / ul >
2016-03-09 20:43:55 -06:00
< p > Note: iRedMail has addition sql table < code > outbound_wblist< / code > to store
white/blacklists for outbound emails, but it's used by iRedAPD (plugin
< code > amavisd_wblist< / code > ), not by Amavisd.< / p >
2015-07-08 10:53:40 -05:00
< / li >
< / ul >
< h2 id = "details" > Details< / h2 >
< h3 id = "lookup_sql_dsn" > < code > @lookup_sql_dsn< / code > < / h3 >
< ul >
< li >
2015-07-09 07:39:05 -05:00
< p > Table < code > amavisd.mailaddr< / code > stores email addresses < strong > NOT< / strong > hosted on your server.< / p >
< p > Note: value of column < code > mailaddr.email< / code > could be something like below:< / p >
2015-07-08 10:53:40 -05:00
< ul >
< li > < code > @.< / code > : a catch-all address.< / li >
< li > < code > @domain.com< / code > : entire domain.< / li >
< li > < code > @.domain.com< / code > : entire domain and all its sub-domains.< / li >
< li > < code > user@domain.com< / code > : a single email address.< / li >
< li > < code > user@*< / code > : email addresses start with < code > user@< / code > . Note: This is used by iRedAPD, not Amavisd.< / li >
< li > < code > 192.168.1.2< / code > : a single IP address. Note: This is used by iRedAPD, not Amavisd.< / li >
< li > < code > 192.168.*.2< / code > : wildcard IP address. Note: This is used by iRedAPD, not Amavisd.< / li >
< / ul >
< p > The addresses are used in several tables:< / p >
< ul >
< li > < code > amavisd.wblist< / code > : used by Amavisd. If sender (of inbound message) is
2015-07-09 07:39:05 -05:00
blacklisted, Amavisd will quarantine this email. But if you have iRedAPD
plugin < code > amavisd_wblist< / code > enabled, this smtp session will be rejected before
queued by Postfix, so Amavisd doesn't know this rejected message at all.< / li >
2015-07-08 10:53:40 -05:00
< li > < code > amavisd.outbound_wblist< / code > . New in iRedMail-0.9.3, used by iRedAPD plugin
< code > amavisd_wblist< / code > for white/blacklisting for outbound message.< / li >
< / ul >
< / li >
< li >
2015-07-09 07:39:05 -05:00
< p > < code > amavisd.users< / code > stores mail addresses hosted on your server. < strong > NOTE< / strong > : you
don't need to sync all existing mail users in this table, just add mail users
you want to define a per-account spam policy in this table.< / p >
< p > Value of column < code > users.email< / code > uses same format as < code > amavisd.mailaddr< / code > mentioned above.< / p >
2015-07-08 10:53:40 -05:00
< / li >
< li >
< p > < code > amavisd.wblist< / code > stores white/blacklists for inbound message. < code > wblist.sid< / code >
(sender id) refers to < code > mailaddr.id< / code > , < code > wblist.rid< / code > (recipient id) refers to
< code > users.id< / code > .< / p >
< / li >
< li >
< p > < code > amavisd.outbound_wblist< / code > stores white/blacklists for outbound message.
< code > outbound_wblist.sid< / code > (sender id) refers to < code > users.id< / code > , < code > outbound_wblist.rid< / code >
(recipient id) refers to < code > mailaddr.id< / code > .< / p >
< p > Note: this table is used by iRedAPD, not Amavisd.< / p >
< / li >
< li >
< p > < code > amavisd.policy< / code > : used to define per-recipient spam policy, and max message
size limit.< / p >
< / li >
2015-07-08 11:25:14 -05:00
< / ul >
< h3 id = "todo-storage_sql_dsn" > TODO: < code > @storage_sql_dsn< / code > < / h3 >
< ul >
< li > < code > maddr< / code > < / li >
< li > < code > msgs< / code > < / li >
< li > < code > msgrcpt< / code > < / li >
< li > < code > quarantine< / code > < / li >
< / ul >
< p > Since Amavisd will store basic info of every inbound/outbound email, the SQL
database will grow bigger and bigger, iRedMail setups a daily cron job to
clean up old records with script shipped in iRedAdmin (available in both
2016-05-19 06:51:20 -05:00
iRedAdmin open source edition and iRedAdmin-Pro): < code > tools/cleanup_amavisd_db.py< / code > .< / p > < div class = "footer" >
< p style = "text-align: center; color: grey;" > All documents are available in < a href = "https://bitbucket.org/zhb/iredmail-docs/src" > BitBucket repository< / a > , and published under < a href = "http://creativecommons.org/licenses/by-nd/3.0/us/" target = "_blank" > Creative Commons< / a > license. You can < a href = "https://bitbucket.org/zhb/iredmail-docs/get/tip.tar.bz2" > download the latest version< / a > for offline reading. If you found something wrong, please do < a href = "http://www.iredmail.org/contact.html" > contact us< / a > to fix it.< / p >
< / div >
< script type = "text/javascript" >
2015-07-08 10:53:40 -05:00
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-3293801-21', 'auto');
ga('send', 'pageview');
< / script >
< / body > < / html >