Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.64 KB | None | 0 0
  1. smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
  2. biff = no
  3. readme_directory = no
  4.  
  5. myhostname = localhost
  6. alias_maps = hash:/etc/aliases
  7. alias_database = hash:/etc/aliases
  8. mydestination = localhost
  9. relayhost =
  10. mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
  11. mailbox_size_limit = 0
  12. recipient_delimiter = +
  13. inet_interfaces = all
  14.  
  15. relay_domains = *
  16. virtual_alias_maps = proxy:mysql:/etc/postfix/virtual_alias_maps.cf
  17. virtual_mailbox_domains = proxy:mysql:/etc/postfix/virtual_mailbox_domains.cf
  18. virtual_mailbox_maps = proxy:mysql:/etc/postfix/virtual_mailbox_maps.cf
  19. virtual_mailbox_base = /home/vmail
  20. virtual_mailbox_limit = 512000000
  21. virtual_minimum_uid = 5000
  22. virtual_transport = virtual
  23. virtual_uid_maps = static:5000
  24. virtual_gid_maps = static:5000
  25. local_transport = virtual
  26. local_recipient_maps = $virtual_mailbox_maps
  27. transport_maps = hash:/etc/postfix/transport
  28.  
  29. smtpd_sasl_auth_enable = yes
  30. smtpd_sasl_type = dovecot
  31. smtpd_sasl_path = /var/run/dovecot/auth-client
  32. smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
  33. smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
  34. smtpd_sasl_security_options = noanonymous
  35. smtpd_sasl_tls_security_options = $smtpd_sasl_security_options
  36. smtpd_tls_auth_only = yes
  37. smtpd_tls_cert_file = /etc/ssl/private/server.crt
  38. smtpd_tls_key_file = /etc/ssl/private/server.key
  39. smtpd_sasl_local_domain = $mydomain
  40. broken_sasl_auth_clients = yes
  41. smtpd_tls_loglevel = 1
  42.  
  43. groupadd -g 5000 vmail
  44. useradd -u 5000 -g vmail -s /usr/bin/nologin -d /home/vmail -m vmail
  45.  
  46. CREATE DATABASE postfix_db;
  47. USE postfix_db;
  48. CREATE USER postfix_user@localhost IDENTIFIED BY 'password';
  49. GRANT ALL ON postfix_db.* TO postfix_user@localhost;
  50. FLUSH PRIVILEGES;
  51.  
  52. CREATE TABLE `domains` (
  53. `domain` varchar(50) NOT NULL default "",
  54. PRIMARY KEY (`domain`),
  55. UNIQUE KEY `domain` (`domain`)
  56. );
  57.  
  58.  
  59. CREATE TABLE `forwardings` (
  60. `source` varchar(80) NOT NULL default "",
  61. `destination` text NOT NULL,
  62. PRIMARY KEY (`source`)
  63. );
  64.  
  65. CREATE TABLE `users` (
  66. `email` varchar(80) NOT NULL default "",
  67. `password` varchar(20) NOT NULL default "",
  68. `quota` varchar(20) NOT NULL default '20971520',
  69. `domain` varchar(255) NOT NULL default "",
  70. UNIQUE KEY `email` (`email`)
  71. );
  72.  
  73. INSERT INTO `domains` VALUES ('virtualdomain.tld');
  74.  
  75. INSERT INTO `users` VALUES ('info@virtualdomain.tld', ENCRYPT('password'), '20971520', 'virtualdomain.tld');
  76.  
  77. cd /etc/ssl/private/
  78. openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out server.key
  79. chmod 400 server.key
  80. openssl req -new -key server.key -out server.csr
  81. openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
  82. chmod 444 server.crt
  83.  
  84. user = postfix_user
  85. password = hunter2
  86. hosts = localhost
  87. dbname = postfix_db
  88. table = domains
  89. select_field = domain
  90. where_field = domain
  91.  
  92. user = postfix_user
  93. password = hunter2
  94. hosts = localhost
  95. dbname = postfix_db
  96. table = forwardings
  97. select_field = destination
  98. where_field = source
  99.  
  100. user = postfix_user
  101. password = hunter2
  102. hosts = localhost
  103. dbname = postfix_db
  104. table = users
  105. select_field = concat(domain,'/',email,'/')
  106. where_field = email
  107.  
  108. touch /etc/postfix/transport
  109. postmap /etc/postfix/transport
  110.  
  111. protocols = imap
  112. auth_mechanisms = plain
  113. passdb {
  114. driver = sql
  115. args = /etc/dovecot/dovecot-sql.conf
  116. }
  117. userdb {
  118. driver = sql
  119. args = /etc/dovecot/dovecot-sql.conf
  120. }
  121.  
  122. service auth {
  123. unix_listener auth-client {
  124. group = postfix
  125. mode = 0660
  126. user = postfix
  127. }
  128. user = root
  129. }
  130.  
  131. mail_home = /home/vmail/%d/%u
  132. mail_location = maildir:~
  133.  
  134. ssl_cert = </etc/ssl/private/server.crt
  135. ssl_key = </etc/ssl/private/server.key
  136.  
  137. driver = mysql
  138. connect = host=localhost dbname=postfix_db user=postfix_user password=hunter2
  139. # The new name for MD5 is MD5-CRYPT so you might need to change this depending on version
  140. default_pass_scheme = MD5-CRYPT
  141. # Get the mailbox
  142. user_query = SELECT '/home/vmail/%d/%u' as home, 'maildir:/home/vmail/%d/%u' as mail, 5000 AS uid, 5000 AS gid, concat('dirsize:storage=', quota) AS quota FROM users WHERE email = '%u'
  143. # Get the password
  144. password_query = SELECT email as user, password, '/home/vmail/%d/%u' as userdb_home, 'maildir:/home/vmail/%d/%u' as userdb_mail, 5000 as userdb_uid, 5000 as userdb_gid FROM users WHERE email = '%u'
  145. # If using client certificates for authentication, comment the above and uncomment the following
  146. #password_query = SELECT null AS password, ā€˜%uā€™ AS user
  147.  
  148. service postfix dovecot restart
  149.  
  150. NOQUEUE: reject: RCPT from blablabla.com[xxx.xxx.xxx.xxx]: 451 4.3.0 <info@virtualdomain.tld>: Temporary lookup failure; from=<my@email.tld> to=<info@virtualdomain.tld> proto=ESMTP helo=<blablabla.com>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement