I did make it all utf-8 but some clients weren't rendering it correctly (perhaps I did it wrong) so I followed what thunderbird was doing instead. Odd thing is I could swear I switched to a ISO-8859-1 charset to get that working and somehow I've reverted back to UTF-8.akreider wrote:Does this have utf-8 support? I'm getting my software to work in unicode so that it will work in 99% of the world's languages.
I'm not sure if you'd want to build-in utf-8 support, or if there is something that programmers should be doing before they get the email text into your script?
I've read something about needing to convert the email text to base64... I guess I'd want to be able to have the email text, subject header, and to: header in unicode.
I'll just test a few things and post back.
EDIT | Latest version should be using ISO-8859-1 by default, but change it to UTF-8 using setCharset() and it should work as UTF-8 but like I say it wasn't rendering certain characters correctly in thunderbird using that charset so I made ISO-8859-1 default. Maybe somebody can help me out on this one?
Here's the key part:
Code: Select all
/**
* Encode a string (mail) in a given format
* Currently supports:
* - BASE64
* - Quoted-Printable
* - Ascii 7-bit
* - Ascii 8bit
* - Binary (not encoded)
*
* @param string input
* @param string encoding
* @return string encoded output
*/
public function encode($string, $type)
{
$type = strtolower($type);
switch ($type)
{
case 'base64':
return base64_encode($string);
break;
//
case 'quoted-printable':
return $this->quotedPrintableEncode($string);
//
case '7bit':
case '8bit':
if (strtoupper($this->charset) != 'UTF-8') return utf8_decode($string);
break;
case 'binary':
default:
break;
}
return $string;
}
// snip //
/**
* Add a part to a multipart message
* @param string body
* @param string content-type, optional
* @param string content-transfer-encoding, optional
* @return void
*/
public function addPart($string, $type='text/plain', $encoding='8bit')
{
$body_string = $this->encode($string, $encoding);
if ($this->autoCompliance && $encoding != 'binary') $body_string = $this->chunkSplitLines($body_string);
$ret = "Content-Type: $type; charset="{$this->charset}"\r\n".
"Content-Transfer-Encoding: $encoding\r\n\r\n".
$body_string;
if (strtolower($type) == 'text/html') $this->parts[] = $this->makeSafe($ret);
else $this->parts = array_merge((array) $this->makeSafe($ret), $this->parts);
}