-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear Darren, dear List,

Darren Cook schrieb:
> As you didn't say explicitly, have you confirmed he can receive an email
> (e.g. sent by thunderbird) in UTF-8 encoding, with umlauts, and it
> displays okay?
> 
> If so, send both versions to yourself (i.e. sent by thunderbird, and
> sent by PHP mail()) and look at the source to see what is different.
This was an obvious method which didn't come to my mind. Thank you very
much!
And thanks a lot to all of you who have answered to my request.

Again for all of you: My problem was "how to send UTF-8 - encoded emails
using the simple mail()-command, that display german umlauts well even
in outlook?"

The solution is very simple:

function sendEmail($to, $from, $subject, $message) {
  // For security reasons: Make sure to parse the parameters
  // before passing them to this function, or extend the code
  // accordingly:

  $charset = 'UTF-8';
  $encoded_subject = "=?$charset?B?".base64_encode($subject)."?=\r\n";
  $headers = "From: " . $from . "\r\n"
    . "Content-Type: text/plain; charset=$charset; format=flowed\r\n"
    . "MIME-Version: 1.0\r\n"
    . "Content-Transfer-Encoding: 8bit\r\n"
    . "X-Mailer: PHP\r\n";

  return mail($to, $encoded_subject, $message, $headers);
}

As I found very few helpful information on this matter on the web and
probably more people have to cope with this problem than there are
experts out there, I hope this solution will be of use for more coders.
There are loads of possibilities to send emails, and there are loads of
header informations you can stuff inside, but finally and hopefully most
of you will only want to use a _working_ UTF-8-solution. We're in 2009
after all...

This solution might not be the best, and it doesn't solve the problem of
emails going right into the recipients (or the recipients mail
provider's) spam folder (for this you should send your emails using SMTP
with login-name and -password, e.g. using PEAR's "Mail.php"). But it
solved my problem.


Best regards,
Roman Blöth.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJtAH4CShhkGXCcigRAvaQAJ97uMZMsdLpVYJ0PDx2rgVzuSHyJwCgj2GH
hQODwinJh4I/x38KsC67XRY=
=tlGG
-----END PGP SIGNATURE-----

-- 
PHP Unicode & I18N Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to