Added option to strip incoming Received headers (#282)

This commit is contained in:
mackinra
2017-08-10 00:05:40 +01:00
committed by Charlie Smurthwaite
parent 457afb90c1
commit 2a9702ba47
2 changed files with 7 additions and 1 deletions
+1
View File
@@ -70,6 +70,7 @@ smtp_server:
tls_private_key_path: # Defaults to config/smtp.key
proxy_protocol: false
log_connect: true
strip_received_headers: false
smtp_relays:
-
+6 -1
View File
@@ -327,7 +327,9 @@ module Postal
@receiving_headers = true
received_header_content = "from #{@helo_name} (#{@hostname} [#{@ip_address}]) by #{Postal.config.dns.smtp_server_hostname} with SMTP; #{Time.now.rfc2822.to_s}".force_encoding('BINARY')
@data << "Received: #{received_header_content}\r\n"
if !Postal.config.smtp_server.strip_received_headers?
@data << "Received: #{received_header_content}\r\n"
end
@headers['received'] = [received_header_content]
handler = Proc.new do |data|
@@ -357,6 +359,9 @@ module Postal
@header_key, value = data.split(/\:\s*/, 2)
@headers[@header_key.downcase] ||= []
@headers[@header_key.downcase] << value
if Postal.config.smtp_server.strip_received_headers? && @header_key.downcase == "received"
next
end
end
end
@data << data