diff options
author | MrZYX <pr0fkill@gmail.com> | 2012-01-21 21:56:32 +0400 |
---|---|---|
committer | MrZYX <pr0fkill@gmail.com> | 2012-01-21 22:16:09 +0400 |
commit | 1ab9520b362701eaebf051cda3fb55e087100367 (patch) | |
tree | 261bd94557e6b7154f565705b1cf4759f56ff20a /app/mailers | |
parent | b831a9b4db27bc53b9b08a7eeb14c4d43c3699ec (diff) |
generate recipient header with Mail::Address to properly handle non-ASCII characters
Diffstat (limited to 'app/mailers')
-rw-r--r-- | app/mailers/notification_mailers/base.rb | 10 | ||||
-rw-r--r-- | app/mailers/notification_mailers/confirm_email.rb | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/app/mailers/notification_mailers/base.rb b/app/mailers/notification_mailers/base.rb index cc17db364..58f55ddc4 100644 --- a/app/mailers/notification_mailers/base.rb +++ b/app/mailers/notification_mailers/base.rb @@ -20,12 +20,18 @@ module NotificationMailers default_headers.merge(@headers) end + def name_and_address(name, email) + address = Mail::Address.new email + address.display_name = name + address.format + end + private def default_headers headers = { :from => AppConfig[:smtp_sender_address], :host => "#{AppConfig[:pod_uri]}", - :to => "\"#{@recipient.name}\" <#{@recipient.email}>" + :to => name_and_address(@recipient.name, @recipient.email) } headers[:from] = "\"#{@sender.name} (Diaspora*)\" <#{AppConfig[:smtp_sender_address]}>" if @sender.present? @@ -48,4 +54,4 @@ module NotificationMailers Rails.logger.info(log_string) end end -end
\ No newline at end of file +end diff --git a/app/mailers/notification_mailers/confirm_email.rb b/app/mailers/notification_mailers/confirm_email.rb index cd94cc76f..ea5fdecca 100644 --- a/app/mailers/notification_mailers/confirm_email.rb +++ b/app/mailers/notification_mailers/confirm_email.rb @@ -1,7 +1,7 @@ module NotificationMailers class ConfirmEmail < NotificationMailers::Base def set_headers - @headers[:to] = "#{@recipient.profile.first_name} <#{@recipient.unconfirmed_email}>" + @headers[:to] = name_and_address(@recipient.profile.first_name, @recipient.unconfirmed_email) @headers[:subject] = I18n.t('notifier.confirm_email.subject', :unconfirmed_email => @recipient.unconfirmed_email) end end |