views:

88

answers:

1

I'ld like to send an email with the following setup

def registration_confirmation(user)
  recipients    user.username + "<" + user.email + ">"
  from          "Netzwerk Muensterland<[email protected]>"
  subject       "Vielen Dank für Ihre Registrierung"
  body          :user => user
  content_type  "text/html"
end

The subject line contains an umlaut and works fine. The log says me, it was encoded like this:

=?utf-8?Q?Vielen_Dank_f=C3=BCr_Ihre_Registrierung?=

But, if the user.username contains umlauts, the email will not send. I am using a google apps smtp server. How do I accomplish a encoding like this for recipients?

+5  A: 

I made it! There is a ActionMailer method called quote_if_necessary which takes care of this kind of problem.

def registration_confirmation(user)
  recipients    quote_if_necessary(user.username, "utf-8") + "<" + user.email + ">"
  from          quote_if_necessary("Netzwerk Münsterland", "utf-8") + " <[email protected]>"
  subject       "Vielen Dank für Ihre Registrierung"
  body          :user => user
  content_type  "text/html"
end
Labuschin