heinzketchup
New Member
- Messages
- 25
- Reaction score
- 0
- Points
- 0
the problem:
you want to send a php mail with utf-8 encoded content and subject(so that the umlaut letters: ö ä ü ß etc. are not shown like this: ö ä ü)... this ain't as easy as you think! it took me about 1 1/2 days to find this solution from this resource: http://sagmueller.net/php-tut/mails.html
I roll it up from the beginning...
i start with the content:
you only have to put this in your php document into the <head> tag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
that's it, now your content is internationally shown the right way... you don't have to worry about this anymore...
now to the problem with the subject that is (for some stupid ASCII reason) still shown wrong...
if your subject is this: $subject="ö ä ü ß";
you only need to write in the next line: $subject = "=?utf-8?b?".base64_encode($subject)."?=";
thats it! we can now start writing the mailing function:
I guess the best way to explain this is just to paste the complete document...
---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>your header here</title>
</head>
<body>
<?
$from="123@456.asdf";
$to = "12345@789.com";//your adress here
$subject = "ö ä ü ß";//your subject here
$subject = "=?utf-8?b?".base64_encode($subject)."?=";
$message = "ä ö ü ß are shown correctly."; //Mail content here (can be html!)
$headers = "From: $from";
$headers .= "\r\n"; //(This is to write paragraphs windows conform...)
$headers .= "Content-type: text/plain";
$headers .= "\r\n\r\n";
mail($to, $subject, $message, $headers);
echo 'mail sent!';
?>
</body>
</html>
---
Thanks for reading my Tut(was my first one, guess everyone noticed that)
PS: you can also send attachments with php!
Rock On Guys->bring me credits (what ever they are used for!?!?)
Edit:
oh man... this will noone ever read! why i do this?
you want to send a php mail with utf-8 encoded content and subject(so that the umlaut letters: ö ä ü ß etc. are not shown like this: ö ä ü)... this ain't as easy as you think! it took me about 1 1/2 days to find this solution from this resource: http://sagmueller.net/php-tut/mails.html
I roll it up from the beginning...
i start with the content:
you only have to put this in your php document into the <head> tag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
that's it, now your content is internationally shown the right way... you don't have to worry about this anymore...
now to the problem with the subject that is (for some stupid ASCII reason) still shown wrong...
if your subject is this: $subject="ö ä ü ß";
you only need to write in the next line: $subject = "=?utf-8?b?".base64_encode($subject)."?=";
thats it! we can now start writing the mailing function:
I guess the best way to explain this is just to paste the complete document...
---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>your header here</title>
</head>
<body>
<?
$from="123@456.asdf";
$to = "12345@789.com";//your adress here
$subject = "ö ä ü ß";//your subject here
$subject = "=?utf-8?b?".base64_encode($subject)."?=";
$message = "ä ö ü ß are shown correctly."; //Mail content here (can be html!)
$headers = "From: $from";
$headers .= "\r\n"; //(This is to write paragraphs windows conform...)
$headers .= "Content-type: text/plain";
$headers .= "\r\n\r\n";
mail($to, $subject, $message, $headers);
echo 'mail sent!';
?>
</body>
</html>
---
Thanks for reading my Tut(was my first one, guess everyone noticed that)
PS: you can also send attachments with php!
Rock On Guys->bring me credits (what ever they are used for!?!?)
Edit:
oh man... this will noone ever read! why i do this?
Last edited: