Page 1 of 1
Mailto with subject
Posted: Wed Jan 16, 2008 4:17 am
by Sindarin
I am trying to add a
subject to an
e-mail link so I've used the command
mailto:a@a.com?subject=test but the problem is the language if I try this with a Greek subject, I get unknown characters in the subject field. I've tried changing my page's encoding to Greek ISO and utf-8, but no good.
Re: Mailto with subject
Posted: Wed Jan 16, 2008 6:05 am
by VladSun
if you wonder how to encode an subject in UTF-8 do it like this:
<?php
mail("
timo.witte@kwick.de", "=?UTF-8?B?".base64_encode("also öhm äähh ühh puh ja die Sonderzeichen")."?=", "asbdasdasd bla blabla", $headers);
?>
=UTF-8?B?[Base64 encoded Subject]?=
The B stands for Base64 you could use Q instead of B and encode your UTF-8 string in 7 bit ASCII but base64 is simpler i think.
why encoding?
because you are not allowed to use 8-bit ASCII in mailheaders only 7-bit ASCII is allowed and pure utf-8 uses 8-bit ASCII characters.
Re: Mailto with subject
Posted: Wed Jan 16, 2008 7:52 am
by Sindarin
Thanks, I understand now..
Re: Mailto with subject
Posted: Sat Jan 19, 2008 9:28 pm
by Chris Corbyn
You can even take it a step further and specify that it's greek.
=?UTF-8*GR?B?[Base64 encoded Subject]?=
That's assuming GR is the language code for greece.
EDIT | To clarify why you'd do that, it's for accessibility. Most screen readers can't read things like greek very well unless you tell them they should be reading greek
