2
votes

I am sending emails via Rails, ActionMailer, 1.9 Ruby and rails 3.0

All is good, I am sending emails with accented characters in subject lines and body, without issue. My charset default is UTF-8.

However when I try to send an email to an address containing accented characters it is failing miserably. I first had errors about the email address being invalid and it needing to be fully qualified.

To get around that, I needed to specify the email address in the format '"" '.

However it is sending now, but the characters in the address on the mail client, appear as =?UTF-8?Q?.... which is correct, Rails is rightly encoding my UTF8 address into the header for me.

BUT

My mail client is not recognising this in its display, so it renders all garbled on screen. garbled as in the actual text =?UTF-8?Q?.... appears in the "To" field on the client.

The encoding is UTF8 etc. charset is UTF8, Transfer Encoding is quotable printable.

What am I missing? It is doing my head in!

Also, as a test, I sent an email from my mac mail client to an address with accented characters. This renders fine in my client, however the headings are totally different... as in the charset is an iso, the transfer encoding is base64.... so I am thinking I need to somehow change actionmailer to encode my mails differently? i.e. using iso and base64 encoding to get it to play nice?

I tried this but to no avail. I am either doing it wrong or completely missing the point here? From readong the various forums and sites on this, I need to encode the header fields in a certain way, but I am failing to find the answers I need to tell me exactly what that encoding is and more specifically how can I do this in Rails?

Please help! :-)

2

2 Answers

1
votes

finally solved this, if you wrap the local part of the email in quotes, and leave the domain part unquoted it works a treat. Seems like Mailer is encoding the full email address if you dont wrap in quotes, and hence breaks the encoding over to the server.

e.g. somé[email protected] wont work

where as "somébody"@here.com will work

routes through fine and displays fine in all clients.

0
votes

Currently not all mail servers support UTF-8 email addresses (aka SMTPUTF8) a lot of them will do crazy things (even content malformation of headers). Can you check to ensure that your encoding header made it all the way through the mail server and wasn't ripped out?

The MTA would have to support RFC6530 to support UTF-8 addresses so it may not be your applications fault.