Jump to content

Getting é instead of é in Outlook


Bogey

Recommended Posts

Hi all, I am building a website, with a contact form...When mail is send from contactform to the website owner, then not all is going wel... When I use this code:

$headers  = 'MIME-Version: 1.0' . "\r\n";$random_hash = md5(date('r', time()));$headers .= 'Content-type: multipart/alternative; boundary="PHP-alt-'.$random_hash.'"' . "\r\n";$headers .= 'From: ' . $afzender . '<' . $mailadres . '>';  $mail_opmaak="---DEZE EMAIL IS VERZONDEN IN HTML FORMAAT, MAAR UW EMAIL PROGRAMMA ONDERSTEUNT DIT NIET. EVENTUELE OPMAAK EN KLIKBARE LINKS ZIJN VERWIJDERD---													   Hier een text versie van de email Enters werken als enters"; $mail_opmaak_html= $mail_opmaak_html . $bericht; $message='--PHP-alt-'.$random_hash.'Content-Type: text/plain; charset="utf-8"Content-Transfer-Encoding: 7bit '.$mail_opmaak.' --PHP-alt-'.$random_hash.'Content-Type: text/html; charset="utf-8"Content-Transfer-Encoding: 7bit '.$mail_opmaak_html.' --PHP-alt-'.$random_hash.'--'; $sentmail = mail($to, $onderwerp, $message, $headers);

then outlook looks like this:optie1.JPG When I use this code:

$headers  = 'MIME-Version: 1.0' . "\r\n";$random_hash = md5(date('r', time()));//$headers .= 'Content-type: multipart/alternative; boundary="PHP-alt-'.$random_hash.'"' . "\r\n";//$headers .= 'From: ' . $afzender . '<' . $mailadres . '>';$headers .= 'Content-type: multipart/alternative; charset="utf-8" boundary="PHP-alt-'.$random_hash.'"' . "\r\n";$headers .= 'From: ' . $afzender . '<' . $mailadres . '>';  $mail_opmaak="---DEZE EMAIL IS VERZONDEN IN HTML FORMAAT, MAAR UW EMAIL PROGRAMMA ONDERSTEUNT DIT NIET. EVENTUELE OPMAAK EN KLIKBARE LINKS ZIJN VERWIJDERD---													   Hier een text versie van de email Enters werken als enters"; $mail_opmaak_html= $mail_opmaak_html . $bericht; $message='--PHP-alt-'.$random_hash.'Content-Type: text/plain; charset="utf-8"Content-Transfer-Encoding: 7bit '.$mail_opmaak.' --PHP-alt-'.$random_hash.'Content-Type: text/html; charset="utf-8"Content-Transfer-Encoding: 7bit '.$mail_opmaak_html.' --PHP-alt-'.$random_hash.'--'; $sentmail = mail($to, $onderwerp, $message, $headers);

then OUTLOOK looks like this:optie2.JPG What I want is that é is shown how it supposed to and not like é in ALL of the following items:1.) From2.) Subject3.) Message Hope you can help me ;)

Edited by Bogey
Link to comment
Share on other sites

I'm not sure of the exact syntax for HTTP headers, but try adding a semi-colon between the parameters: $headers .= 'Content-type: multipart/alternative; charset="utf-8"; boundary="PHP-alt-'.$random_hash.'"' . "\r\n";

Link to comment
Share on other sites

The appearance of headers is NOT determined by the Content-Type of the message. The header must contain its own type instructions. EDIT SEE NEXT POST What you want is some sort of iconv function. I've experimented with this, and here is the closest I can come to the exact solution

$preferences = array(   "input-charset" => "UTF-8",   "output-charset" => "ISO-8859-1");$preferences["scheme"] = "Q";$h = iconv_mime_encode("", $subject, $preferences);

This outputs something like this, which is fine

: =?ISO-8859-1?Q?H=E9llo?=

but the first two characters (": ") need to be stripped. If there is a truly perfect solution, someone else might know it. In theory, you should be able to do this:

$h = iconv_mime_encode("Subject", $subject, $preferences);

and that would give you a perfectly formed mail header. And this will work for most headers, such as BCC. But it doesn't work with the Subject header, because the mail() function creates its own Subject header. All you are permitted to send is the value of the subject header, and iconv_mime_encode() returns a name-value pair formatted as a complete header string. All this should be true for the TO header also.

Edited by Deirdre's Dad
Link to comment
Share on other sites

OK, additional research turns up a much easier solution:

$s = '=?UTF-8?B?' . base64_encode($subject) . '?=';mail($to, $s, "My message");

Edited by Deirdre's Dad
Link to comment
Share on other sites

Did between familie apointments a quick try... ;) Still not working... But your talking about the "subject" part, but that was already quite working how supposed... (see first post)The problem is the sender/from thing, the $to....

Link to comment
Share on other sites

When I only use this code:

$to = 'info@inselsem.nl';if(!empty($_GET['c'])){$onderwerp = stripslashes($_GET['c']);} $subject = '=?UTF-8?B?' . base64_encode($onderwerp) . '?=';$sentmail = mail($to, $subject, "My message");

then I get this:optie11.JPG

Edited by Bogey
Link to comment
Share on other sites

Okay, start over ;)I cleared the automaticfilled adress in Outlook... This is my code:

<?phpfunction br2nl( $input ) {return preg_replace('/<br(\s+)?\/?>/i', "\n", $input);} if(!empty($_GET['a'])){$afzender = stripslashes($_GET['a']);}if(!empty($_GET['b'])){$mailadres = stripslashes($_GET['b']);}if(!empty($_GET['c'])){$onderwerp = stripslashes($_GET['c']);}if(!empty($_GET['d'])){$bericht = stripslashes($_GET['d']);} $to = 'info@inselsem.nl';$subject = '=?UTF-8?B?' . base64_encode($onderwerp) . '?='; $protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https')=== FALSE ? 'http' : 'https';$host = $_SERVER['HTTP_HOST'];$website = $protocol . '://' . $host; $headers  = 'MIME-Version: 1.0' . "\r\n";$random_hash = md5(date('r', time()));$headers .= 'Content-type: multipart/alternative; boundary="PHP-alt-'.$random_hash.'"' . "\r\n";$headers .= 'From: ' . $afzender . '<' . $mailadres . '>'; $mail_opmaak="---DEZE EMAIL IS VERZONDEN IN HTML FORMAAT, MAAR UW EMAIL PROGRAMMA ONDERSTEUNT DIT NIET. EVENTUELE OPMAAK EN KLIKBARE LINKS ZIJN VERWIJDERD---													   Hier een text versie van de email Enters werken als enters"; $mail_opmaak_html= $mail_opmaak_html . $bericht; $message='--PHP-alt-'.$random_hash.'Content-Type: text/plain; charset="utf-8"Content-Transfer-Encoding: 7bit '.$mail_opmaak.' --PHP-alt-'.$random_hash.'Content-Type: text/html; charset="utf-8"Content-Transfer-Encoding: 7bit '.$mail_opmaak_html.' --PHP-alt-'.$random_hash.'--'; $sentmail = mail($to, $subject, $message, $headers); if($sentmail){?><p align='center'>GOOD...!</p><?php}else {?><p align='center'>FAULT...!</p><?phpreturn;}?>

Subject and message show é....The From shows éRené <mail@gmail.com> So just the from needs to be fixed... I think, this problem has to be an issue for lot of people, cause many use Outlook...Or am I just stupid, that I cant get it right? :fool:

Edited by Bogey
Link to comment
Share on other sites

YEAH....!!! now its working how supposed to ;)

$to = 'info@mail.nl';$subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';$sender = '=?UTF-8?B?' . base64_encode($sender) . '?='; $headers  = 'MIME-Version: 1.0' . "\r\n";$random_hash = md5(date('r', time()));$headers .= 'Content-type: multipart/alternative; boundary="PHP-alt-'.$random_hash.'"' . "\r\n";$headers .= 'From: ' . $sender . '<' . $mailadres . '>';

This works....!!! thnx thnx thnx thnx thnx

Edited by Bogey
Link to comment
Share on other sites

Not totally solved :S other problem! I want for example the name "René" written to the mysql database, but I dont get the é there... I get:éé but noté this is in my code:

<meta http-equiv="X-UA-Compatible" content="IE=8" /><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><meta http-equiv="Content-Language" content="nl" />

I tried different things:

$sender = stripslashes($_GET['a']);} $sender= utf8_encode($sender);$sender= '=?UTF-8?B?' . base64_encode($sender) . '?=';

Coallitions tried in mysql:utf8_binutf8_general_cilatin1_general_cilatin1_swedish_ci any sollutions??? And a question for dutch coders here (also for english speaking, but I prefer dutch, cause I think this is a difficult item):Is there a course/book/topic where the uncoding issue is being explained from scratch to advanced....?

Edited by Bogey
Link to comment
Share on other sites

Your database should use the UTF8 general encoding. You need to change the content type on your page so that it is using UTF8, and you might also want to save your actual files using UTF8. After that, try to insert normally or using utf8_encode to see which works.

Link to comment
Share on other sites

Yes, that was it!!!!But why decode, if page is charset utf8 and database is coalition utf8? thnx again! ;)

Edited by Bogey
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...