Differences


This shows you the differences between two versions of the page.

wiki:general:postfix [2010/07/20 12:59]
ali
wiki:general:postfix [2010/07/20 19:00] (current)
ali
Line 1: Line 1:
 +====== Postfix ======
 +===== main.cfg =====
 +<code>
 +myhostname = HOSTNAME
 +mydomain = $myhostname
 +myorigin = $mydomain
 +mydestination = localhost
 +mynetworks_style = host
 +relay_domains = $mydestination
 +
 +home_mailbox = Maildir/
 +
 +virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
 +virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
 +virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
 +virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
 +
 +virtual_mailbox_base = /srv/vmails
 +virtual_uid_maps = static:5000
 +virtual_gid_maps = static:5000
 +virtual_minimum_uid = 5000
 +
 +virtual_mailbox_limit = 51200000
 +#virtual_create_maildirsize = yes
 +#virtual_mailbox_extended = yes
 +virtual_mailbox_limit_override = yes
 +virtual_maildir_limit_message = Sorry, the user's maildir has no space available in their inbox.
 +virtual_overquota_bounce = yes
 +</code>
 +
 +==== Add vmail user ====
 +Adding vmail user with group vmail and give him access to **virtual_mailbox_base** which is srv/vmails in our case.
 +<code>
 +groupadd -g 5000 vmail
 +useradd -g vmail -u 5000 -d srv/vmails -s /bin/false vmail
 +mkdir srv/vmails
 +chown vmail:vmail srv/vmails
 +chmod -R 750 srv/vmails
 +</code>
 +
 +
 +
 +====== MYSQL ======
 +===== virtual_mailbox_domains =====
 +
 +
 +<code>
 +CREATE TABLE `domains` (
 +  `domain` varchar(50) NOT NULL default '',
 +  PRIMARY KEY  (`domain`),
 +  UNIQUE KEY `domain` (`domain`)
 +);
 +</code>
 +
 +/etc/postfix/mysql_virtual_domains_maps.cf
 +<code>
 +hosts = localhost
 +dbname = DBNAME
 +user = username
 +password = password
 +table = domains
 +select_field = domain
 +where_field = domain
 +</code>
 +
 +===== virtual_mailbox_maps  =====
 +
 +<code>
 +CREATE TABLE `mail_boxes` (
 +`email` varchar(255) NOT NULL default '',
 +`password` varchar(255) NOT NULL default '',
 +`maildir` varchar(255) NOT NULL default '',
 +`quota` int(10) NOT NULL default '0',
 +`domain` varchar(255) NOT NULL default '',
 +`active` BOOLEAN NOT NULL default true
 +);
 +</code>
 +
 +/etc/postfix/mysql_virtual_mailbox_maps.cf
 +<code>
 +hosts = localhost
 +dbname = DBNAME
 +user = username
 +password = password
 +table = mail_boxes
 +select_field = CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')
 +where_field = email
 +additional_conditions = and active = '1'
 +</code>
 +
 +===== virtual_mailbox_limit_maps =====
 +/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
 +
 +<code>
 +hosts = localhost
 +dbname = DBNAME
 +user = username
 +password = password
 +table = mail_boxes
 +select_field = quota
 +where_field = email
 +</code>
 +
 +
 +===== virtual_alias_maps =====
 +
 +**Mail aliases**
 +
 +<code>
 +CREATE TABLE `alias` (
 +`email` varchar(255) NOT NULL default '',
 +`goto` text NOT NULL,
 +`domain` varchar(255) NOT NULL default '',
 +PRIMARY KEY (`email`),
 +KEY `domain` (`domain`)
 +)
 +
 +</code>
 +
 +
 +/etc/postfix/mysql_virtual_alias_maps.cf
 +<code>
 +
 +hosts = localhost
 +dbname = DBNAME
 +user = username
 +password = password
 +table = alias
 +select_field = goto
 +where_field = email
 +</code>
 +
 +===== SSL support =====
 +<code>
 +openssl req -new -x509 -newkey rsa:2048 -days 365 -keyout server.key -out server.crt
 +cp server.key server.key.orig
 +openssl rsa -in server.key -out server.key
 +chmod 0400 server.key server.key.orig
 +</code>
 +
 +
 +===== Spam assassin =====
 +Install spamassasin, you may need to symlink **spamc**
 +
 +<code>
 +ln -sv /usr/bin/perlbin/vendor/spamc /usr/bin/spamc
 +</code>
 +
 +Pipe mails through spamassassin:
 +  * /etc/postfix/master.cf
 +<code>
 +smtp      inet  n       -       n       -       -       smtpd -o content_filter=spamassassin
 +spamassassin    unix    -       n       n       -       -       pipe user=nobody argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
 +</code>
 +  * /etc/mail/spamassassin/local.cf or
 +  * /etc/spamassassin/local.cf
 +<code>
 +rewrite_header Subject [***** SPAM _SCORE_ *****]
 +required_score           2.0
 +#to be able to use _SCORE_ we need report_safe set to 0
 +#If this option is set to 0, incoming spam is only modified by adding some "X-Spam-" headers and no changes will be made to the body.
 +report_safe     0
 +
 +# Enable the Bayes system
 +use_bayes               1
 +use_bayes_rules         1
 +# Enable Bayes auto-learning
 +bayes_auto_learn        1
 +
 +# Enable or disable network checks
 +skip_rbl_checks         0
 +use_razor2              0
 +use_dcc                 0
 +use_pyzor               0
 +</code>
 
wiki/general/postfix.txt · Last modified: 2010/07/20 19:00 by ali
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported