Forum Moderators: coopster

Message Too Old, No Replies

Looking for sendmail class (utf8 content / spec. characters in header)

sendmail class / utf8 / special characters

         

tnobs

2:15 pm on Mar 6, 2008 (gmt 0)

10+ Year Member



Hej hej

I'm looking for a PHP sendmail class, which is able to send utf8 encoded body, and where the special characters are shown right in the header, like: "Thömas <tom@hotmail.com>"

Is it possible to send both versions in one mail, text and html ?

I have tested now several classes and functions, but I always run into problems with special characters in the header, the subject field isn't that problem .. more the mailFromName etc.

Any links and tips welcome, thanks tnobs

jatar_k

2:18 pm on Mar 6, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> Is it possible to send both versions in one mail, text and html ?

yes

>> always run into problems with special characters in the header

what problems exactly?

tnobs

2:55 pm on Mar 6, 2008 (gmt 0)

10+ Year Member



Hej

I'm working here in Sweden, where they have ä ö å in the alphabet.

So for example if you have:
From: Hänson <hanson@hotmail.com>
To: johan@hotmail.com
Subject: Här ar min link
Body: Hej Johan

Klicka här om du vill ladar filen.

The mail body is utf8 encoded, and is working fine. Sometimes I have problems with the "-" character in a special mail client (first class).
But this is ok.

When it comes to special characters in the name (From), ... hotmail, gmail, thunderbird... etc. is working... but not every mail client (gmx, first class).

I'm looking for a mail class, which is able to send text or html mails, without any character problems.

If somebody knows one, I pay you a beer.... ;-)

For example, if I create my own header, like:

function send_mail_text($to, $body, $subject, $fromaddress, $fromname)
{

$header = '';

$textboundary = uniqid(time());
$charset = "UTF-8";

$header .= 'From: '.$fromname.'<'.$fromaddress.'>'."\r\n";
$header .= 'MIME-Version: 1.0'."\r\n";

$header .= 'Content-Type: text/plain; charset="'.$charset.'"'."\r\n";
$header .= strip_tags($body)."\r\n\r\n";

if(preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})/i",$to)) {

$subject = '=?'.$charset.'?B?' . base64_encode($subject) . '?=';

mail($to,$subject,"",$header);
return true;

} else {

return false;
}
}

Here, I have the problem with the mail name from, if it's "Thömas" for example.

Thanks Norbert