Advertisement
Guest User

Untitled

a guest
Dec 27th, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.37 KB | None | 0 0
  1. Hi there,
  2. I made a mailserver with dovecot + postfix on debian. I can send and recieve emails. Also the server detects spam emails.
  3.  
  4. Unfortunately, Sieve does not sort out Spam Mails to a Spam folder. Thats why i am here.
  5.  
  6. Here are some Files I edited:
  7.  
  8. dovecot.conf
  9. <pre>
  10. <code>
  11. ## Dovecot configuration file
  12.  
  13. # If you're in a hurry, see http://wiki2.dovecot.org/QuickConfiguration
  14.  
  15. # "doveconf -n" command gives a clean output of the changed settings. Use it
  16. # instead of copy&pasting files when posting to the Dovecot mailing list.
  17.  
  18. # '#' character and everything after it is treated as comments. Extra spaces
  19. # and tabs are ignored. If you want to use either of these explicitly, put the
  20. # value inside quotes, eg.: key = "# char and trailing whitespace "
  21.  
  22. # Most (but not all) settings can be overridden by different protocols and/or
  23. # source/destination IPs by placing the settings inside sections, for example:
  24. # protocol imap { }, local 127.0.0.1 { }, remote 10.0.0.0/8 { }
  25.  
  26. # Default values are shown for each setting, it's not required to uncomment
  27. # those. These are exceptions to this though: No sections (e.g. namespace {})
  28. # or plugin settings are added by default, they're listed only as examples.
  29. # Paths are also just examples with the real defaults being based on configure
  30. # options. The paths listed here are for configure --prefix=/usr
  31. # --sysconfdir=/etc --localstatedir=/var
  32.  
  33. # Enable installed protocols
  34. !include_try /usr/share/dovecot/protocols.d/*.protocol
  35.  
  36. # A comma separated list of IPs or hosts where to listen in for connections.
  37. # "*" listens in all IPv4 interfaces, "::" listens in all IPv6 interfaces.
  38. # If you want to specify non-default ports or anything more complex,
  39. # edit conf.d/master.conf.
  40. # Alex edited
  41. listen = *
  42.  
  43. # Base directory where to store runtime data.
  44. #base_dir = /var/run/dovecot/
  45.  
  46. # Name of this instance. In multi-instance setup doveadm and other commands
  47. # can use -i <instance_name> to select which instance is used (an alternative
  48. # to -c <config_path>). The instance name is also added to Dovecot processes
  49. # in ps output.
  50. #instance_name = dovecot
  51.  
  52. # Greeting message for clients.
  53. #login_greeting = Dovecot ready.
  54.  
  55. # Space separated list of trusted network ranges. Connections from these
  56. # IPs are allowed to override their IP addresses and ports (for logging and
  57. # for authentication checks). disable_plaintext_auth is also ignored for
  58. # these networks. Typically you'd specify your IMAP proxy servers here.
  59. #login_trusted_networks =
  60.  
  61. # Space separated list of login access check sockets (e.g. tcpwrap)
  62. #login_access_sockets =
  63.  
  64. # With proxy_maybe=yes if proxy destination matches any of these IPs, don't do
  65. # proxying. This isn't necessary normally, but may be useful if the destination
  66. # IP is e.g. a load balancer's IP.
  67. #auth_proxy_self =
  68.  
  69. # Show more verbose process titles (in ps). Currently shows user name and
  70. # IP address. Useful for seeing who are actually using the IMAP processes
  71. # (eg. shared mailboxes or if same uid is used for multiple accounts).
  72. #verbose_proctitle = no
  73.  
  74. # Should all processes be killed when Dovecot master process shuts down.
  75. # Setting this to "no" means that Dovecot can be upgraded without
  76. # forcing existing client connections to close (although that could also be
  77. # a problem if the upgrade is e.g. because of a security fix).
  78. #shutdown_clients = yes
  79.  
  80. # If non-zero, run mail commands via this many connections to doveadm server,
  81. # instead of running them directly in the same process.
  82. #doveadm_worker_count = 0
  83. # UNIX socket or host:port used for connecting to doveadm server
  84. #doveadm_socket_path = doveadm-server
  85.  
  86. # Space separated list of environment variables that are preserved on Dovecot
  87. # startup and passed down to all of its child processes. You can also give
  88. # key=value pairs to always set specific settings.
  89. #import_environment = TZ
  90.  
  91. ##
  92. ## Dictionary server settings
  93. ##
  94.  
  95. # Dictionary can be used to store key=value lists. This is used by several
  96. # plugins. The dictionary can be accessed either directly or though a
  97. # dictionary server. The following dict block maps dictionary names to URIs
  98. # when the server is used. These can then be referenced using URIs in format
  99. # "proxy::<name>".
  100.  
  101. dict {
  102. #quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
  103. #expire = sqlite:/etc/dovecot/dovecot-dict-sql.conf.ext
  104. }
  105.  
  106. # Most of the actual configuration gets included below. The filenames are
  107. # first sorted by their ASCII value and parsed in that order. The 00-prefixes
  108. # in filenames are intended to make it easier to understand the ordering.
  109. !include conf.d/*.conf
  110.  
  111. # A config file can also tried to be included without giving an error if
  112. # it's not found:
  113. !include_try local.conf
  114.  
  115.  
  116. auth_mechanisms = plain login
  117. log_timestamp = "%Y-%m-%d %H:%M:%S "
  118. passdb {
  119. args = /etc/dovecot/dovecot-mysql.conf
  120. driver = sql
  121. }
  122. protocols = imap pop3 sieve
  123. # Alex edit diese zeile
  124. mail_home = /var/vmail/%d/%n
  125. # Alex edit done
  126.  
  127. service auth {
  128. unix_listener /var/spool/postfix/private/auth_dovecot {
  129. group = postfix
  130. mode = 0660
  131. user = postfix
  132. }
  133. unix_listener auth-master {
  134. mode = 0660
  135. user = vmail
  136. }
  137. user = root
  138. }
  139. ssl = yes
  140. ssl_cert = </etc/postfix/ssl/mailserver.crt
  141. ssl_key = </etc/postfix/ssl/mailserver.key
  142. userdb {
  143. args = /etc/dovecot/dovecot-mysql.conf
  144. driver = sql
  145. }
  146. protocol pop3 {
  147. pop3_uidl_format = %08Xu%08Xv
  148. pop3_client_workarounds = oe-ns-eoh
  149. # pop3_uidl_format = %v.%u
  150. }
  151. protocol lda {
  152. auth_socket_path = /var/run/dovecot/auth-master
  153. postmaster_address = alexander@example.com
  154. mail_plugins = sieve
  155. #log_path = /var/log/sieve.log
  156. }
  157. #
  158. #
  159. #
  160. #
  161. #
  162. # Alex Settings :D
  163.  
  164. lda_mailbox_autosubscribe = yes
  165. lda_mailbox_autocreate = yes
  166.  
  167. namespace inbox {
  168. mailbox Spam {
  169. auto = subscribe
  170. special_use = \Junk
  171. }
  172.  
  173. mailbox Entwürfe {
  174. auto = create
  175. special_use = \Drafts
  176. }
  177. }
  178.  
  179.  
  180. plugin {
  181. sieve_before = /var/vmail/sieve/spam-global.sieve
  182. sieve_dir = /var/vmail/%d/%n/sieve/scripts/
  183. sieve = /var/vmail/%d/%n/sieve/active-script.sieve
  184. }
  185.  
  186. #plugin {
  187. # sieve_global_path = /var/lib/dovecot/sieve/default.sieve
  188. # sieve_global_dir = /var/lib/dovecot/sieve/
  189. #}
  190.  
  191. #plugin {
  192. # Eigene Sieve Filter liegen im Heimverzeichnis
  193. # sieve = ~/sieve/dovecot.sieve
  194. # sieve_dir = ~/sieve
  195. # Der globale Filter außerhalb
  196. # sieve_before = /var/vmail/before.sieve
  197. # sieve_max_script_size = 1M
  198. # sieve_quota_max_scripts = 0
  199. # sieve_quota_max_storage = 0
  200. #}
  201.  
  202. service managesieve-login {
  203. inet_listener sieve {
  204. port = 4190
  205. }
  206. service_count = 1
  207. process_min_avail = 2
  208. vsz_limit = 128M
  209. }
  210. service managesieve {
  211. process_limit = 256
  212. }
  213. protocol sieve {
  214. managesieve_logout_format = bytes=%i/%o
  215. }
  216.  
  217. mail_debug = yes
  218.  
  219. log_path = /var/log/dovecot.log
  220. # If you want everything in one file, just don't specify info_log_path and debug_log_path
  221. info_log_path = /var/log/dovecot-info.log
  222. # Leave empty in order to send debug-level messages to info_log_path
  223. debug_log_path = /var/log/dovecot-debug.log
  224.  
  225. </code>
  226. </pre>
  227.  
  228.  
  229. 15-lda.conf
  230.  
  231. <pre>
  232. <code>
  233. ##
  234. ## LDA specific settings (also used by LMTP)
  235. ##
  236.  
  237. # Address to use when sending rejection mails.
  238. # Default is postmaster@<your domain>. %d expands to recipient domain.
  239. postmaster_address = alexander@example.com
  240.  
  241. # Hostname to use in various parts of sent mails (e.g. in Message-Id) and
  242. # in LMTP replies. Default is the system's real hostname@domain.
  243. hostname = example.com
  244.  
  245. # If user is over quota, return with temporary failure instead of
  246. # bouncing the mail.
  247. #quota_full_tempfail = no
  248.  
  249. # Binary to use for sending mails.
  250. #sendmail_path = /usr/sbin/sendmail
  251.  
  252. # If non-empty, send mails via this SMTP host[:port] instead of sendmail.
  253. #submission_host =
  254.  
  255. # Subject: header to use for rejection mails. You can use the same variables
  256. # as for rejection_reason below.
  257. #rejection_subject = Rejected: %s
  258.  
  259. # Human readable error message for rejection mails. You can use variables:
  260. # %n = CRLF, %r = reason, %s = original subject, %t = recipient
  261. #rejection_reason = Your message to <%t> was automatically rejected:%n%r
  262.  
  263. # Delimiter character between local-part and detail in email address.
  264. #recipient_delimiter = +
  265.  
  266. # Header where the original recipient address (SMTP's RCPT TO: address) is taken
  267. # from if not available elsewhere. With dovecot-lda -a parameter overrides this.
  268. # A commonly used header for this is X-Original-To.
  269. #lda_original_recipient_header =
  270.  
  271. # Should saving a mail to a nonexistent mailbox automatically create it?
  272. lda_mailbox_autocreate = yes
  273.  
  274. # Should automatically created mailboxes be also automatically subscribed?
  275. lda_mailbox_autosubscribe = yes
  276.  
  277. protocol lda {
  278. # Space separated list of plugins to load (default is global mail_plugins).
  279. mail_plugins = $mail_plugins sieve
  280. }
  281.  
  282. </code>
  283. </pre>
  284.  
  285. master.cf
  286.  
  287. <pre>
  288. <code>
  289. #
  290. # Postfix master process configuration file. For details on the format
  291. # of the file, see the master(5) manual page (command: "man 5 master" or
  292. # on-line: http://www.postfix.org/master.5.html).
  293. #
  294. # Do not forget to execute "postfix reload" after editing this file.
  295. #
  296. # ==========================================================================
  297. # service type private unpriv chroot wakeup maxproc command + args
  298. # (yes) (yes) (yes) (never) (100)
  299. # ==========================================================================
  300. smtp inet n - - - - smtpd
  301. #smtp inet n - - - 1 postscreen
  302. #smtpd pass - - - - - smtpd
  303. #dnsblog unix - - - - 0 dnsblog
  304. #tlsproxy unix - - - - 0 tlsproxy
  305. submission inet n - - - - smtpd
  306. # -o syslog_name=postfix/submission
  307. # -o smtpd_tls_security_level=encrypt
  308. # -o smtpd_sasl_auth_enable=yes
  309. # -o smtpd_reject_unlisted_recipient=no
  310. # -o smtpd_client_restrictions=$mua_client_restrictions
  311. # -o smtpd_helo_restrictions=$mua_helo_restrictions
  312. # -o smtpd_sender_restrictions=$mua_sender_restrictions
  313. # -o smtpd_recipient_restrictions=
  314. # -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
  315. # -o milter_macro_daemon_name=ORIGINATING
  316. smtps inet n - - - - smtpd
  317. # -o syslog_name=postfix/smtps
  318. -o smtpd_tls_wrappermode=yes
  319. # -o smtpd_sasl_auth_enable=yes
  320. # -o smtpd_reject_unlisted_recipient=no
  321. # -o smtpd_client_restrictions=$mua_client_restrictions
  322. # -o smtpd_helo_restrictions=$mua_helo_restrictions
  323. # -o smtpd_sender_restrictions=$mua_sender_restrictions
  324. # -o smtpd_recipient_restrictions=
  325. # -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
  326. # -o milter_macro_daemon_name=ORIGINATING
  327. #628 inet n - - - - qmqpd
  328. pickup unix n - - 60 1 pickup
  329. -o content_filter=
  330. -o receive_override_options=no_header_body_checks
  331. cleanup unix n - - - 0 cleanup
  332. qmgr unix n - n 300 1 qmgr
  333. #qmgr unix n - n 300 1 oqmgr
  334. tlsmgr unix - - - 1000? 1 tlsmgr
  335. rewrite unix - - - - - trivial-rewrite
  336. bounce unix - - - - 0 bounce
  337. defer unix - - - - 0 bounce
  338. trace unix - - - - 0 bounce
  339. verify unix - - - - 1 verify
  340. flush unix n - - 1000? 0 flush
  341. proxymap unix - - n - - proxymap
  342. proxywrite unix - - n - 1 proxymap
  343. smtp unix - - - - - smtp
  344. relay unix - - - - - smtp
  345. # -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
  346. showq unix n - - - - showq
  347. error unix - - - - - error
  348. retry unix - - - - - error
  349. discard unix - - - - - discard
  350. local unix - n n - - local
  351. virtual unix - n n - - virtual
  352. lmtp unix - - - - - lmtp
  353. anvil unix - - - - 1 anvil
  354. scache unix - - - - 1 scache
  355. #
  356. # ====================================================================
  357. # Interfaces to non-Postfix software. Be sure to examine the manual
  358. # pages of the non-Postfix software to find out what options it wants.
  359. #
  360. # Many of the following services use the Postfix pipe(8) delivery
  361. # agent. See the pipe(8) man page for information about ${recipient}
  362. # and other message envelope options.
  363. # ====================================================================
  364. #
  365. # maildrop. See the Postfix MAILDROP_README file for details.
  366. # Also specify in main.cf: maildrop_destination_recipient_limit=1
  367. #
  368. maildrop unix - n n - - pipe
  369. flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
  370. #
  371. # ====================================================================
  372. #
  373. # Recent Cyrus versions can use the existing "lmtp" master.cf entry.
  374. #
  375. # Specify in cyrus.conf:
  376. # lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
  377. #
  378. # Specify in main.cf one or more of the following:
  379. # mailbox_transport = lmtp:inet:localhost
  380. # virtual_transport = lmtp:inet:localhost
  381. #
  382. # ====================================================================
  383. #
  384. # Cyrus 2.1.5 (Amos Gouaux)
  385. # Also specify in main.cf: cyrus_destination_recipient_limit=1
  386. #
  387. #cyrus unix - n n - - pipe
  388. # user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
  389. #
  390. # ====================================================================
  391. # Old example of delivery via Cyrus.
  392. #
  393. #old-cyrus unix - n n - - pipe
  394. # flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
  395. #
  396. # ====================================================================
  397. #
  398. # See the Postfix UUCP_README file for configuration details.
  399. #
  400. uucp unix - n n - - pipe
  401. flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
  402. #
  403. # Other external delivery methods.
  404. #
  405. ifmail unix - n n - - pipe
  406. flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
  407. bsmtp unix - n n - - pipe
  408. flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
  409. scalemail-backend unix - n n - 2 pipe
  410. flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
  411. mailman unix - n n - - pipe
  412. flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  413. ${nexthop} ${user}
  414.  
  415. #Alex edit
  416. #dovecot unix - n n - - pipe
  417. # flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient}
  418.  
  419. dovecot unix - n n - - pipe
  420. flags=ODRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -e -f ${sender} -d ${recipient}
  421.  
  422.  
  423. smtp-amavis unix - - - - 2 smtp
  424. -o smtp_data_done_timeout=1200
  425. -o smtp_send_xforward_command=yes
  426. -o disable_dns_lookups=yes
  427. -o max_use=20
  428. -o smtp_tls_security_level=none
  429.  
  430. 127.0.0.1:10025 inet n - - - - smtpd
  431. -o content_filter=
  432. -o local_recipient_maps=
  433. -o relay_recipient_maps=
  434. -o smtpd_restriction_classes=
  435. -o smtpd_delay_reject=no
  436. -o smtpd_client_restrictions=permit_mynetworks,reject
  437. -o smtpd_helo_restrictions=
  438. -o smtpd_sender_restrictions=
  439. -o smtpd_recipient_restrictions=permit_mynetworks,reject
  440. -o smtpd_data_restrictions=reject_unauth_pipelining
  441. -o smtpd_end_of_data_restrictions=
  442. -o mynetworks=127.0.0.0/8
  443. -o smtpd_error_sleep_time=0
  444. -o smtpd_soft_error_limit=1001
  445. -o smtpd_hard_error_limit=1000
  446. -o smtpd_client_connection_count_limit=0
  447. -o smtpd_client_connection_rate_limit=0
  448. -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks
  449. -o smtpd_tls_security_level=none
  450.  
  451. </code>
  452. </pre>
  453.  
  454. main.cf
  455.  
  456. <pre>
  457. <code>
  458. # See /usr/share/postfix/main.cf.dist for a commented, more complete version
  459.  
  460.  
  461. # Debian specific: Specifying a file name will cause the first
  462. # line of that file to be used as the name. The Debian default
  463. # is /etc/mailname.
  464. #myorigin = /etc/mailname
  465.  
  466. smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
  467. biff = no
  468.  
  469. # appending .domain is the MUA's job.
  470. append_dot_mydomain = no
  471.  
  472. # Uncomment the next line to generate "delayed mail" warnings
  473. #delay_warning_time = 4h
  474.  
  475. readme_directory = no
  476.  
  477. # TLS parameters
  478. smtpd_tls_cert_file=/etc/postfix/ssl/mailserver.crt
  479. smtpd_tls_key_file=/etc/postfix/ssl/mailserver.key
  480. smtpd_use_tls=yes
  481. smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
  482. smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
  483. smtpd_tls_security_level = may
  484.  
  485. # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
  486. # information on enabling SSL in the smtp client.
  487.  
  488. smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
  489. myhostname = debianServer
  490. alias_maps = hash:/etc/aliases
  491. alias_database = hash:/etc/aliases
  492. myorigin = /etc/mailname
  493. mydestination = virtual_mailbox_domains, example.com, debianServer, localhost.localdomain, localhost
  494. relayhost =
  495. mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
  496. mailbox_command = /usr/lib/dovecot/deliver
  497. mailbox_transport = dovecot
  498. mailbox_size_limit = 0
  499. recipient_delimiter = +
  500. inet_interfaces = all
  501.  
  502. # a bit more spam protection
  503. disable_vrfy_command = yes
  504.  
  505.  
  506. # Auth
  507. smtpd_sasl_type=dovecot
  508. smtpd_sasl_path=private/auth_dovecot
  509. smtpd_sasl_auth_enable = yes
  510. smtpd_sasl_authenticated_header = yes
  511. broken_sasl_auth_clients = yes
  512.  
  513. 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 $transport_maps $mynetworks $smtpd_sender_login_maps
  514.  
  515. smtpd_sender_login_maps = proxy:mysql:/etc/postfix/mysql-sender-login-maps.cf
  516.  
  517. smtpd_sender_restrictions = reject_authenticated_sender_login_mismatch
  518. reject_unknown_sender_domain
  519.  
  520. smtpd_recipient_restrictions = permit_sasl_authenticated
  521. permit_mynetworks
  522. reject_unauth_destination
  523.  
  524.  
  525. # Virtual mailboxes
  526. virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual-alias-maps.cf
  527. virtual_mailbox_base = /var/vmail/
  528. virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual-domains-maps.cf
  529. virtual_mailbox_limit = 0
  530. virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
  531. virtual_minimum_uid = 104
  532. virtual_transport = dovecot
  533. local_transport = virtual
  534. virtual_uid_maps = static:6000
  535. virtual_gid_maps = static:6000
  536. dovecot_destination_recipient_limit = 1
  537.  
  538. # Alex EDIT 1337 haxor
  539. content_filter=smtp-amavis:[127.0.0.1]:10024
  540.  
  541. </code>
  542. </pre>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement