From a02505f996b02a4313c9e266b88fbe7b844fb8da Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 18 Sep 2018 20:36:54 +0200 Subject: Convert hash keys to symbols for mail delivery settings. --- lib/registration.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/registration.rb b/lib/registration.rb index b82cdb4..6fc4b9a 100644 --- a/lib/registration.rb +++ b/lib/registration.rb @@ -12,7 +12,14 @@ def send_registration_emails_for(band, pdf_url) mail.body = erb :registration_email, :layout => false, :locals => { :pdf_url => pdf_url } if settings.environment != :test && settings.respond_to?(:smtp) - mail.delivery_method :smtp, settings.smtp + # Since the sinatra/indifferent_hash implementation that holds + # the settings converts all keys to strings, and the mail gem + # expects the keys as symbols, we need to create a new hash + # with the correct keys. + smtp_settings = Hash[settings.smtp.map { |e| [e[0].to_sym, e[1]] }] + + logger.debug "smtp settings: #{smtp_settings.inspect}" + mail.delivery_method :smtp, smtp_settings end mail.deliver! rescue Net::SMTPError => e -- cgit v1.2.3