Empty header
wgc-bf opened this issue · comments
After upgrading to rails 3.2.13, we get this error:
Net::SMTPFatalError (554 Transaction failed: Empty header names are illegal.):
Which we tracked down to recipient_interceptor. The issue is that it is adding an extra new line to the original header, which already ended with a new line character.
The extra empty line has been converted to a ':' which is illegal.
The offending code is found in recipient_interceptor.rb:
def add_custom_headers(message)
{
'X-Intercepted-To' => message.to || [],
'X-Intercepted-Cc' => message.cc || [],
'X-Intercepted-Bcc' => message.bcc || []
}.each do |header, addresses|
addresses.each do |address|
message.header = "#{message.header}\n#{header}: #{address}"
end
end
end
We found the following fixed the issue (at least on our systems):
def add_custom_headers(message)
{
'X-Intercepted-To' => message.to || [],
'X-Intercepted-Cc' => message.cc || [],
'X-Intercepted-Bcc' => message.bcc || []
}.each do |header, addresses|
addresses.each do |address|
message.header = "#{message.header.to_s.chomp}\n#{header}: #{address}"
end
end
end