From 68e9cf96d31639770113b768536186189d6c1f12 Mon Sep 17 00:00:00 2001 From: Matthias Fetzer Date: Tue, 17 Apr 2018 12:51:11 +0200 Subject: [PATCH] Made relayhost optional --- README.md | 4 ++-- manifests/init.pp | 2 +- templates/Debian/etc/postfix/main.cf.erb | 4 ++++ templates/Gentoo/etc/postfix/main.cf.erb | 5 ++++- templates/Ubuntu/etc/postfix/main.cf.erb | 4 ++++ 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7b1da78..c1738b9 100644 --- a/README.md +++ b/README.md @@ -307,8 +307,8 @@ Determines which email address should be used for the redirecting. Defaults to " #### `relayhost` -Determines which host should be used as relayhost for outgoing emails. Defaults -to "smtp.${::domain}". +Determines which host should be used as relayhost for outgoing emails. By default +no relay host is set and e-mail is transmitted directly. #### `relayport` diff --git a/manifests/init.pp b/manifests/init.pp index b7f2721..794b264 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -31,7 +31,7 @@ $myhostname = $::fqdn, $mydestination = "${::fqdn}, localhost.${::domain}, localhost", $recipient = "admin@${::domain}", - $relayhost = "smtp.${::domain}", + $relayhost = undef, $relayport = 25, $sasl_user = undef, $sasl_pass = undef, diff --git a/templates/Debian/etc/postfix/main.cf.erb b/templates/Debian/etc/postfix/main.cf.erb index 0bb5965..d7419c8 100644 --- a/templates/Debian/etc/postfix/main.cf.erb +++ b/templates/Debian/etc/postfix/main.cf.erb @@ -48,7 +48,11 @@ alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = <%= scope['::postfix::mydestination'] %> + +<% if scope['::postfix::relayhost'] -%> relayhost = [<%= scope['::postfix::relayhost'] -%>]:<%= scope['::postfix::relayport'] %> +<% end -%> + mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_command = procmail -a "$EXTENSION" mailbox_size_limit = 0 diff --git a/templates/Gentoo/etc/postfix/main.cf.erb b/templates/Gentoo/etc/postfix/main.cf.erb index 8822f8a..e61c1bf 100644 --- a/templates/Gentoo/etc/postfix/main.cf.erb +++ b/templates/Gentoo/etc/postfix/main.cf.erb @@ -325,7 +325,10 @@ mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 #relayhost = [mailserver.isp.tld] #relayhost = uucphost #relayhost = [an.ip.add.ress] -relayhost = <%= scope.lookupvar('::postfix::relayhost') %> +# +<% if scope['::postfix::relayhost'] -%> +relayhost = [<%= scope['::postfix::relayhost'] -%>]:<%= scope['::postfix::relayport'] %> +<% end -%> # REJECTING UNKNOWN RELAY USERS # diff --git a/templates/Ubuntu/etc/postfix/main.cf.erb b/templates/Ubuntu/etc/postfix/main.cf.erb index d8cda85..fc28c81 100644 --- a/templates/Ubuntu/etc/postfix/main.cf.erb +++ b/templates/Ubuntu/etc/postfix/main.cf.erb @@ -51,7 +51,11 @@ alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = <%= scope['::postfix::mydestination'] %> + +<% if scope['::postfix::relayhost'] -%> relayhost = [<%= scope['::postfix::relayhost'] -%>]:<%= scope['::postfix::relayport'] %> +<% end -%> + mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = +