PHPMailer : Language string failed to load: instantiate

This problem were driving me nuts for a couple of hours so I decided to post it here, to the benefit of others. Using the PHPMailer class to send mail to members from one of our sites I were writing a new function, but all of a sudden my mailing function refused to cooperate, and would return the error:

Language string failed to load: instantiate

This mysterious error came out of the blue, since I’d been using the same function for a long time without any hassle. After going through every bit of the problem it boiled down to not having anything to do with any Language string, which one would believe, but the interesting part of the error message is  instantiate. 

It turned out that I was sending a subject header encoded as UTF-8, which the PHPMailer class would reject since it contained a perculiar swedish letter, namely “å”. Other swedish letters like “ä” and “ö” will work just fine encoded as UTF-8. But not “å”.

The solution? Simple enough, as always:

$subject = utf8_decode("Någon har svarat på din fråga på $site");

This converts the string to ISO-8859-1 encoding, which, of course, worked fine.

Popularity: 10% [?]

2 Comments Posted in PHP, web development

2 Comments

  1. Hey! Thanks a lot for sharing this knowledge. Quite helpful :)

  2. Verrrrrrrrrrrrrrry goooooooodddddddd you save my life

Leave a Reply

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>