Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2012
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.61 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5.  
  6. ---
  7.  
  8. # Database SQL
  9.  
  10. -- phpMyAdmin SQL Dump
  11. -- version 3.4.7.1
  12. -- [url]http://www.phpmyadmin.net[/url]
  13. --
  14. -- Host: localhost
  15. -- Generation Time: Dec 19, 2011 at 11:59 PM
  16. -- Server version: 5.1.58
  17. -- PHP Version: 5.3.6-13ubuntu3.3
  18.  
  19. SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
  20. SET time_zone = "+00:00";
  21.  
  22.  
  23. /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  24. /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  25. /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  26. /*!40101 SET NAMES utf8 */;
  27.  
  28. --
  29. -- Database: `postfix`
  30. --
  31.  
  32. -- --------------------------------------------------------
  33.  
  34. --
  35. -- Table structure for table `admin`
  36. --
  37.  
  38. CREATE TABLE IF NOT EXISTS `admin` (
  39. `username` varchar(255) NOT NULL DEFAULT '',
  40. `password` varchar(255) NOT NULL DEFAULT '',
  41. `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  42. `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  43. `active` tinyint(1) NOT NULL DEFAULT '1',
  44. PRIMARY KEY (`username`),
  45. KEY `username` (`username`)
  46. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Virtual Admins';
  47.  
  48. -- --------------------------------------------------------
  49.  
  50. --
  51. -- Table structure for table `alias`
  52. --
  53.  
  54. CREATE TABLE IF NOT EXISTS `alias` (
  55. `address` varchar(255) CHARACTER SET latin1 NOT NULL DEFAULT '',
  56. `goto` text CHARACTER SET latin1 NOT NULL,
  57. `domain` varchar(255) CHARACTER SET latin1 NOT NULL DEFAULT '',
  58. `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  59. `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  60. `active` tinyint(1) NOT NULL DEFAULT '1',
  61. PRIMARY KEY (`address`),
  62. KEY `address` (`address`)
  63. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Virtual Aliases';
  64.  
  65. -- --------------------------------------------------------
  66.  
  67. --
  68. -- Table structure for table `alias_domain`
  69. --
  70.  
  71. CREATE TABLE IF NOT EXISTS `alias_domain` (
  72. `alias_domain` varchar(255) NOT NULL DEFAULT '',
  73. `target_domain` varchar(255) NOT NULL DEFAULT '',
  74. `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  75. `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  76. `active` tinyint(1) NOT NULL DEFAULT '1',
  77. PRIMARY KEY (`alias_domain`),
  78. KEY `active` (`active`),
  79. KEY `target_domain` (`target_domain`)
  80. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Domain Aliases';
  81.  
  82. -- --------------------------------------------------------
  83.  
  84. --
  85. -- Table structure for table `config`
  86. --
  87.  
  88. CREATE TABLE IF NOT EXISTS `config` (
  89. `id` int(11) NOT NULL AUTO_INCREMENT,
  90. `name` varchar(20) NOT NULL DEFAULT '',
  91. `value` varchar(20) NOT NULL DEFAULT '',
  92. PRIMARY KEY (`id`),
  93. UNIQUE KEY `name` (`name`)
  94. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='PostfixAdmin settings' AUTO_INCREMENT=1 ;
  95.  
  96. -- --------------------------------------------------------
  97.  
  98. --
  99. -- Table structure for table `domain`
  100. --
  101.  
  102. CREATE TABLE IF NOT EXISTS `domain` (
  103. `domain` varchar(255) NOT NULL DEFAULT '',
  104. `description` varchar(255) NOT NULL DEFAULT '',
  105. `aliases` int(10) NOT NULL DEFAULT '0',
  106. `mailboxes` int(10) NOT NULL DEFAULT '0',
  107. `maxquota` bigint(10) NOT NULL DEFAULT '0',
  108. `quota` bigint(20) NOT NULL DEFAULT '0',
  109. `transport` varchar(255) DEFAULT NULL,
  110. `backupmx` tinyint(1) NOT NULL DEFAULT '0',
  111. `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  112. `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  113. `active` tinyint(1) NOT NULL DEFAULT '1',
  114. PRIMARY KEY (`domain`),
  115. KEY `domain` (`domain`)
  116. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Virtual Domains';
  117.  
  118. -- --------------------------------------------------------
  119.  
  120. --
  121. -- Table structure for table `domain_admins`
  122. --
  123.  
  124. CREATE TABLE IF NOT EXISTS `domain_admins` (
  125. `username` varchar(255) NOT NULL DEFAULT '',
  126. `domain` varchar(255) NOT NULL DEFAULT '',
  127. `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  128. `active` tinyint(1) NOT NULL DEFAULT '1',
  129. KEY `username` (`username`)
  130. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Domain Admins';
  131.  
  132. -- --------------------------------------------------------
  133.  
  134. --
  135. -- Table structure for table `fetchmail`
  136. --
  137.  
  138. CREATE TABLE IF NOT EXISTS `fetchmail` (
  139. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  140. `mailbox` varchar(255) NOT NULL DEFAULT '',
  141. `src_server` varchar(255) NOT NULL DEFAULT '',
  142. `src_auth` enum('password','kerberos_v5','kerberos','kerberos_v4','gssapi','cram-md5','otp','ntlm','msn','ssh','any') DEFAULT NULL,
  143. `src_user` varchar(255) NOT NULL DEFAULT '',
  144. `src_password` varchar(255) NOT NULL DEFAULT '',
  145. `src_folder` varchar(255) NOT NULL DEFAULT '',
  146. `poll_time` int(11) unsigned NOT NULL DEFAULT '10',
  147. `fetchall` tinyint(1) unsigned NOT NULL DEFAULT '0',
  148. `keep` tinyint(1) unsigned NOT NULL DEFAULT '0',
  149. `protocol` enum('POP3','IMAP','POP2','ETRN','AUTO') DEFAULT NULL,
  150. `extra_options` text,
  151. `returned_text` text,
  152. `mda` varchar(255) NOT NULL DEFAULT '',
  153. `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  154. PRIMARY KEY (`id`)
  155. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Fetchmail' AUTO_INCREMENT=1 ;
  156.  
  157. -- --------------------------------------------------------
  158.  
  159. --
  160. -- Table structure for table `log`
  161. --
  162.  
  163. CREATE TABLE IF NOT EXISTS `log` (
  164. `timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  165. `username` varchar(255) NOT NULL DEFAULT '',
  166. `domain` varchar(255) NOT NULL DEFAULT '',
  167. `action` varchar(255) NOT NULL DEFAULT '',
  168. `data` varchar(255) NOT NULL DEFAULT '',
  169. KEY `timestamp` (`timestamp`)
  170. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Log';
  171.  
  172. -- --------------------------------------------------------
  173.  
  174. --
  175. -- Table structure for table `mailbox`
  176. --
  177.  
  178. CREATE TABLE IF NOT EXISTS `mailbox` (
  179. `username` varchar(255) NOT NULL DEFAULT '',
  180. `password` varchar(255) NOT NULL DEFAULT '',
  181. `name` varchar(255) NOT NULL DEFAULT '',
  182. `maildir` varchar(255) NOT NULL DEFAULT '',
  183. `quota` bigint(20) NOT NULL DEFAULT '-1',
  184. `domain` varchar(255) NOT NULL DEFAULT '',
  185. `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  186. `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  187. `active` tinyint(1) NOT NULL DEFAULT '1',
  188. `local_part` varchar(255) NOT NULL,
  189. PRIMARY KEY (`username`),
  190. KEY `username` (`username`)
  191. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Virtual Mailboxes';
  192.  
  193. -- --------------------------------------------------------
  194.  
  195. --
  196. -- Table structure for table `vacation`
  197. --
  198.  
  199. CREATE TABLE IF NOT EXISTS `vacation` (
  200. `email` varchar(255) NOT NULL DEFAULT '',
  201. `subject` varchar(255) NOT NULL DEFAULT '',
  202. `body` text NOT NULL,
  203. `cache` text NOT NULL,
  204. `domain` varchar(255) NOT NULL DEFAULT '',
  205. `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  206. `active` tinyint(4) NOT NULL DEFAULT '1',
  207. PRIMARY KEY (`email`),
  208. KEY `email` (`email`)
  209. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Virtual Vacation';
  210.  
  211. -- --------------------------------------------------------
  212.  
  213. --
  214. -- Table structure for table `vacation_notification`
  215. --
  216.  
  217. CREATE TABLE IF NOT EXISTS `vacation_notification` (
  218. `on_vacation` varchar(170) NOT NULL,
  219. `notified` varchar(170) NOT NULL,
  220. `notified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  221. PRIMARY KEY (`on_vacation`,`notified`)
  222. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Virtual Vacation Notifications';
  223.  
  224. --
  225. -- Constraints for dumped tables
  226. --
  227.  
  228. --
  229. -- Constraints for table `vacation_notification`
  230. --
  231. ALTER TABLE `vacation_notification`
  232. ADD CONSTRAINT `vacation_notification_ibfk_1` FOREIGN KEY (`on_vacation`) REFERENCES `vacation` (`email`) ON DELETE CASCADE;
  233.  
  234. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  235. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  236. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  237.  
  238.  
  239. # /etc/postfix/mysql_virtual_alias_maps.cf:
  240. user = postfix
  241. password = postfixpassword
  242. hosts = 127.0.0.1
  243. dbname = postfix
  244. table = alias
  245. select_field = goto
  246. where_field = address
  247.  
  248. # /etc/postfix/mysql_virtual_domains_maps.cf:
  249. user = postfix
  250. password = postfixpassword
  251. hosts = 127.0.0.1
  252. dbname = postfix
  253. table = domain
  254. select_field = domain
  255. where_field = domain
  256. additional_conditions = and backupmx = '0' and active = '1'
  257.  
  258. # /etc/postfix/mysql_virtual_mailbox_maps.cf:
  259. user = postfix
  260. password = postfixpassword
  261. hosts = 127.0.0.1
  262. dbname = postfix
  263. table = mailbox
  264. select_field = maildir
  265. where_field = username
  266. additional_conditions = and active = '1'
  267.  
  268. # /etc/postfix/mysql_virtual_mailbox_limit_maps.cf:
  269. user = postfix
  270. password = postfixpassword
  271. hosts = 127.0.0.1
  272. dbname = postfix
  273. table = mailbox
  274. select_field = quota
  275. where_field = username
  276. additional_conditions = and active = '1'
  277.  
  278. # /etc/postfix/mysql_relay_domains_maps.cf:
  279. user = postfix
  280. password = postfixpassword
  281. hosts = 127.0.0.1
  282. dbname = postfix
  283. table = domain
  284. select_field = domain
  285. where_field = domain
  286. additional_conditions = and backupmx = '1'
  287.  
  288. # make postfix configuration files viewable to postfix user only:
  289. sudo chgrp postfix /etc/postfix/mysql_*.cf
  290. sudo chmod 640 /etc/postfix/mysql_*.cf
  291.  
  292. # Create a vmail user by running these commands:
  293. sudo groupadd -g 5000 vmail
  294. sudo useradd -g vmail -u 5000 vmail -d /home/vmail -m
  295.  
  296. # Create certificates for TLS
  297. openssl req -new -outform PEM -out /etc/postfix/smtpd.cert -newkey rsa:2048 -nodes -keyout /etc/postfix/smtpd.key -keyform PEM -days 3650 -x509
  298. chmod 640 /etc/postfix/smtpd.key
  299.  
  300. # Enable secure ports: 465 and 587 (/etc/postfix/master.cf)
  301. smtps inet n - - - - smtpd
  302. -o smtpd_tls_wrappermode=yes
  303. -o smtpd_sasl_auth_enable=yes
  304. -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  305. -o milter_macro_daemon_name=ORIGINATING
  306. 587 inet n - - - - smtpd
  307.  
  308. # /etc/postfix/main.cf:
  309. virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
  310. virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
  311. virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
  312. virtual_mailbox_base = /home/vmail
  313. virtual_uid_maps = static:5000
  314. virtual_gid_maps = static:5000
  315. smtpd_sasl_auth_enable = yes
  316. smtpd_helo_required = yes
  317. broken_sasl_auth_clients = yes
  318. smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
  319. smtpd_use_tls = yes
  320. smtpd_tls_cert_file = /etc/postfix/smtpd.cert
  321. smtpd_tls_key_file = /etc/postfix/smtpd.key
  322. strict_rfc821_envelopes = yes
  323. disable_vrfy_command = yes
  324. virtual_create_maildirsize = yes
  325. virtual_mailbox_extended = yes
  326. virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
  327. virtual_mailbox_limit_override = yes
  328. virtual_maildir_limit_message = "Account is over quota"
  329. virtual_overquota_bounce = yes
  330. proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $mynetworks $virtual_mailbox_limit_maps
  331.  
  332. # Set up permissions for postfix to use sasl, or you will get error: SASL authentication failure
  333. sudo adduser postfix sasl
  334.  
  335. # /etc/courier/authdaemonrc (add DEBUG_LOGIN=2 if you want to log password in /var/log/mail)
  336. authmodulelist="authmysql"
  337.  
  338. # /etc/courier/authmysqlrc:
  339. MYSQL_SERVER 127.0.0.1
  340. MYSQL_USERNAME postfix
  341. MYSQL_PASSWORD thepassword
  342. MYSQL_DATABASE postfix
  343. MYSQL_USER_TABLE mailbox
  344. MYSQL_LOGIN_FIELD username
  345. MYSQL_NAME_FIELD name
  346. MYSQL_CRYPT_PWFIELD password
  347. #MYSQL_CLEAR_PWFIELD password
  348. MYSQL_MAILDIR_FIELD maildir
  349. MYSQL_QUOTA_FIELD concat(quota,'S')
  350. MYSQL_HOME_FIELD '/home/vmail'
  351. MYSQL_UID_FIELD '5000'
  352. MYSQL_GID_FIELD '5000'
  353.  
  354. # /etc/postfix/sasl/smtpd.conf:
  355. #sql_engine: mysql # might not be needed, try with out it
  356. pwcheck_method: saslauthd
  357. mech_list: plain login
  358. allow_plaintext: true
  359. auxprop_plugin: mysql
  360. sql_hostnames: 127.0.0.1
  361. sql_database: postfix
  362. sql_user: username
  363. sql_passwd: password
  364. sql_select: select password from mailbox where username='%u@%r' and active = 1
  365.  
  366. # Create a folder for the SASL PID file
  367. mkdir -p /var/spool/postfix/var/run/saslauthd
  368.  
  369. # Enable SASL (/etc/default/saslauthd)
  370. START=yes
  371. OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"
  372. NAME="saslauthd"
  373. MECHANISMS="pam"
  374.  
  375. # Configure SASL to use the new PID file location (pico /etc/init.d/saslauthd)
  376. # Make sure you replace all PIDFILE definations in the file. This is set on a few places.
  377. PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"
  378.  
  379. # Configure PAM to use MySql backend for authentication (/etc/pam.d/smtp)
  380. auth required pam_mysql.so user=username passwd=password host=127.0.0.1 db=mail table=users usercolumn=email passwdcolumn=password crypt=1
  381. account sufficient pam_mysql.so user=username passwd=password host=127.0.0.1 db=mail table=users usercolumn=email passwdcolumn=password crypt=1
  382.  
  383. # saslauthd seems to be buggy in Ubuntu 11.10: [url]https://bugs.launchpad.net/ubuntu/+s...l2/+bug/875440[/url]
  384. You can solve the problem by installing the saslauthd packages from Ubuntu 11.04:
  385. apt-get install libsqlite0 db4.8-util libssl0.9.8
  386. cd /tmp
  387. mkdir sasl
  388. cd sasl
  389. wget [url]http://archive.ubuntu.com/ubuntu/pool/main/c/cyrus-sasl2/libsasl2-2_2.1.23.dfsg1-5ubuntu3_i386.deb[/url] [url]http://archive.ubuntu.com/ubuntu/pool/main/c/cyrus-sasl2/libsasl2-modules_2.1.23.dfsg1-5ubuntu3_i386.deb[/url] [url]http://archive.ubuntu.com/ubuntu/pool/main/c/cyrus-sasl2/libsasl2-modules-sql_2.1.23.dfsg1-5ubuntu3_i386.deb[/url] [url]http://archive.ubuntu.com/ubuntu/pool/main/c/cyrus-sasl2/libsasl2-dev_2.1.23.dfsg1-5ubuntu3_i386.deb[/url] [url]http://archive.ubuntu.com/ubuntu/pool/main/c/cyrus-sasl2/sasl2-bin_2.1.23.dfsg1-5ubuntu3_i386.deb[/url]
  390. dpkg -i *.deb
  391.  
  392. # Restart daemons
  393. sudo /etc/init.d/saslauthd restart
  394. sudo /etc/init.d/postfix restart
  395. sudo /etc/init.d/courier-authdaemon restart
  396. sudo /etc/init.d/courier-imap restart
  397. sudo /etc/init.d/courier-imap-ssl restart
  398. sudo /etc/init.d/courier-pop restart
  399. sudo /etc/init.d/courier-pop-ssl restart
  400.  
  401. Note: If something goes wrong, go to:
  402. [url]https://help.ubuntu.com/community/PostfixCompleteVirtualMailSystemHowto[/url] to step-by-step guide on how to do it properly
  403. [url]http://www.debiantutorials.com/installing-postfix-with-mysql-backend-and-sasl-for-smtp-authentication/[/url]
  404. [url]http://www.debiantutorials.com/installing-courier-pop3-and-imap-daemon-with-mysql-backend-install-courier/[/url]
  405. [url]http://codepoets.co.uk/2009/postfixadmin-setupinstall-guide-for-virtual-mail-users-on-postfix/[/url]
  406.  
  407. Don't forget to save extra addons to the locations below (read their documentation, it's inside of every .sh file)
  408. /usr/local/bin/postfixadmin-mailbox-postcreation.sh
  409. /usr/local/bin/postfixadmin-mailbox-postdeletion.sh
  410. /usr/local/bin/postfixadmin-domain-postdeletion.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement