E-Mail only accepts ASCII characters as many MTAs are not equipped to correctly relay other messages. You should think of MIME-E-Mails like onions: (they smell, they make you cry) and they have layers. The HTML message (inner layer) only gets decoded after the plain text of your message is handled (outer layer).
You need to explicitly encode any non-ASCII characters in the “outer” layer. You do this using the Content-Transfer-Encoding
header, which can be set to either base64
or quoted-printable
(some modern MTAs also support 8bit
or binary
but these must be set explicitly and support still isn’t as universal as one would hope for in 2014). Of course the MIME part that follows this header also needs to be actually encoded using the method specified. Fortunately Base64-Encoding is only a base64_encode
call away.
Alternatively, since your message is in HTML (and you don’t seem to care about providing a plaintext alternative – which you should), you could also use HTML’s escaping mechanisms (e.g. í
instead of í
), but Base64 is generally safer since it’s immune to the MTAs that take it upon themselves to break up long lines after 78 characters.