Permalink
Browse files

Simple mail-drop config for Postfix to be used in app servers

  • Loading branch information...
1 parent a7bd5cc commit 0acc1db0b47a625ca6526ac4cd6e4a0110858436 Cosimo Streppone committed Feb 23, 2012
Showing with 180 additions and 0 deletions.
  1. +18 −0 postfix/files/postfix.preseed
  2. +53 −0 postfix/manifests/init.pp
  3. +72 −0 postfix/templates/main.cf.erb
  4. +37 −0 postfix/templates/master.cf.erb
@@ -0,0 +1,18 @@
+postfix postfix/root_address string
+postfix postfix/rfc1035_violation boolean false
+postfix postfix/mydomain_warning boolean
+postfix postfix/mynetworks string 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
+postfix postfix/mailname string host.domain.com
+postfix postfix/tlsmgr_upgrade_warning boolean
+postfix postfix/recipient_delim string +
+postfix postfix/main_mailer_type select No configuration
+postfix postfix/destinations string localhost
+postfix postfix/retry_upgrade_warning boolean
+postfix postfix/kernel_version_warning boolean
+postfix postfix/not_configured error
+postfix postfix/mailbox_limit string 0
+postfix postfix/relayhost string
+postfix postfix/procmail boolean false
+postfix postfix/bad_recipient_delimiter error
+postfix postfix/protocols select all
+postfix postfix/chattr boolean false
View
@@ -0,0 +1,53 @@
+class postfix {
+
+ include munin
+
+ $preseed_file="/var/tmp/postfix.preseed"
+
+ file { $preseed_file:
+ ensure => "present",
+ source => "puppet:///modules/postfix/postfix.preseed",
+ mode => 0600,
+ backup => "false",
+ }
+
+ package { "postfix":
+ ensure => "installed",
+ responsefile => $preseed_file,
+ require => File[$preseed_file],
+ }
+
+ service { "postfix":
+ ensure => "running",
+ enable => "true",
+ require => Package["postfix"],
+ }
+
+ munin::plugin { "postfix_mailqueue": }
+ munin::plugin { "postfix_mailstats": }
+ munin::plugin { "postfix_mailvolume": }
+
+}
+
+define postfix::config (
+ $mode="delivery-only",
+ $mydomain="",
+ $relayhost=""
+) {
+
+ file { "/etc/postfix/main.cf":
+ ensure => "present",
+ content => template("postfix/main.cf.erb"),
+ notify => Service["postfix"],
+ require => Package["postfix"],
+ }
+
+ file { "/etc/postfix/master.cf":
+ ensure => "present",
+ content => template("postfix/master.cf.erb"),
+ notify => Service["postfix"],
+ require => Package["postfix"],
+ }
+
+}
+
@@ -0,0 +1,72 @@
+# Managed by puppet. Edits will be lost.
+
+# $Revision$
+
+#-------------------------------------------------------
+# Postfix config for smtp delivery only
+#
+# Used by application servers to drop mail locally
+# and have it delivered externally
+#-------------------------------------------------------
+
+queue_directory = /var/spool/postfix
+command_directory = /usr/sbin
+mail_owner = postfix
+default_privs = nobody
+
+sendmail_path = /usr/sbin/sendmail
+manpage_path = /usr/local/man
+setgid_group = postdrop
+newaliases_path = /usr/bin/newaliases
+mailq_path = /usr/bin/mailq
+
+readme_directory = no
+sample_directory = /etc/postfix
+manpage_directory = /usr/local/man
+html_directory = no
+
+# This defaults to gethostname(), see postconf(5)
+#myhostname =
+<% if mydomain %>
+mydomain = <%= mydomain %>
+myorigin = $mydomain
+<% end %>
+
+# postfix normally adds @$myorigin to any To/Cc email addresses
+# that don't have a domain part. Don't want that
+# so we just set no rewrite clients
+local_header_rewrite_clients =
+append_dot_mydomain = no
+
+# Trusted networks we'll relay email from
+mynetworks = 127.0.0.1 10.0.0.0/8
+
+# Domains that will deliver locally rather than forwarding
+mydestination =
+
+<% if relayhost %>
+relayhost = <%= relayhost %>
+<% else %>
+# relayhost = [your.relay.host.here]:25
+<% end %>
+
+# Increase sending timeout limits because of dumb receiving hosts
+transport_retry_time = 20s
+stale_lock_time = 180s
+smtp_connect_timeout = 190s
+smtp_helo_timeout = 190s
+smtp_mail_timeout = 190s
+smtp_rcpt_timeout = 190s
+smtp_data_xfer_timeout = 190s
+smtp_quit_timeout = 30s
+max_idle = 30s
+
+# How long emails are queued for. Never want warnings about delays
+maximal_queue_lifetime = 24h
+delay_warning_time = 0h
+
+# Drop bounce emails if they bounce
+bounce_queue_lifetime = 0
+
+# To test that outgoing mail is going through
+# always_bcc = someone@domain.tld
@@ -0,0 +1,37 @@
+# Managed by puppet. Edits will be lost.
+
+# $Revision$
+
+## BASE POSTFIX CONFIG
+pickup fifo n - n 60 1 pickup
+cleanup unix n - n - 0 cleanup
+qmgr fifo n - n 300 1 qmgr
+rewrite unix - - n - - trivial-rewrite
+bounce unix - - n - 0 bounce
+defer unix - - n - 0 bounce
+showq unix n - n - - showq
+error unix - - n - - error
+local unix - n n - - local
+flush unix n - n 1000? 0 flush
+relay unix - - n - - smtp
+trace unix - - n - 0 bounce
+verify unix - - n - 1 verify
+proxymap unix - - n - - proxymap
+anvil unix - - n - 1 anvil
+scache unix - - n - 1 scache
+discard unix - - n - - discard
+tlsmgr unix - - n 1000? 1 tlsmgr
+retry unix - - - - - error
+
+## SMTP TARGET CONFIG
+smtp unix - - n - 100 smtp
+
+## SMTPD LISTENING CONFIG
+
+<% if mode == "delivery-only" %>
+# We're only sending email, so no smtpd needed
+# *:smtp inet n - n - 50 smtpd
+<% else %>
+*:smtp inet n - n - 50 smtpd
+<% end %>
+

0 comments on commit 0acc1db

Please sign in to comment.