Using any moderm graphical e-mail client you are able to send e-mails in Unicode, so that your local script is shown in the To:, From:, Subject:, and body fields. However, when you design a Website that sends e-mails to users or you want to send notification e-mail from a script, often it is difficult to get the encoding right and show the local language properly.
Here we see how to send fully localised e-mail from PHP. Similar steps can be taken with other scripting languages.
You need to configure PHP on the server to use the mbstring extension. In popular distributions it is already installed with PHP. Verify that along with the package "php" you also have "php-mbstring" installed as well.
Then, you configure the default language settings for mbstring, so that your scripts are simpler. As we opt for Unicode and utf-8, these settings are universal. The following section should already exist in your distribution (at least on my Fedora Core 2), but commented out.
; language for internal character representation.
; -> "Neutral" is for Unicode.
mbstring.language = Neutral
; internal/script encoding.
; Some encoding cannot work as internal encoding.
; (e.g. SJIS, BIG5, ISO-2022-*)
mbstring.internal_encoding = UTF-8
; http input encoding.
; -> Setup your Web pages to be in utf-8 and specify utf-8 in HTML headers.
; -> Sometimes Apache is configured to send the encoding in the HTTP headers.
; -> ..which is set to iso-8859-1 (Debian?). Don't omit that setting.
mbstring.http_input = UTF-8
; http output encoding. mb_output_handler must be
; registered as output buffer to function
mbstring.http_output = UTF-8
; enable automatic encoding translation accoding to
; mbstring.internal_encoding setting. Input chars are
; converted to internal encoding by setting this to On.
; Note: Do _not_ use automatic encoding translation for
; portable libs/applications.
mbstring.encoding_translation = On
; automatic encoding detection order.
; auto means
mbstring.detect_order = auto
; substitute_character used when character cannot be converted
; one from another
; -> if character code not found, show as U+xxxx. Good for finding issues.
mbstring.substitute_character = long;
Finally, you can send localised e-mail through the following script. You can either execute it from command line (php mailtest.php) or add it as a Web page and visit it.
$from = "From: \"" . mb_encode_mimeheader('Αυτά είναι ελληνικά') . "\" <root@localhost>";
$to = mb_encode_mimeheader('Παραλήπτης') . " <firstname.lastname@example.org>";
$subject = 'Θέμα';
$body = 'Περιεχόμενο του γράμματος';
mb_send_mail($to, $subject, $body, $from);
The strings in Unicode (utf-8) I am using for the example should be Greek to you.