- A simple UTF-8(Unicode Transformation Format) mail sender function is mainly used to encode subject and plain-text message to UTF-8.
- If we need to send the HTML mail form text/plain to text/html, this function is usable but in most cases without any modification. Here is the simple function we use to send email in UTF-8.
Sample Script For Sending Email In Utf-8:
<?php
function mail_utf8($to, $from_user, $from_email, $subject = '(No subject)', $message = '')
{
$from_user = "=?UTF-8?".base64_encode($from_user)."?=";
$subject = "=?UTF-8?".base64_encode($subject)."?=";
$headers = "From: $from_user <$from_email>\r\n". "MIME-Version: 1.0" . "\r\n" . "Content-type: text/html; charset=UTF-8" . "\r\n";
return mail($to, $subject, $message, $headers);
}
?>
Applies to:
Related Tags:
- php - How to send UTF-8 email?
- How to send correct UTF-8 mail in PHP
- Using UTF-8 characters on an e-mail subject