By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,749 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,749 IT Pros & Developers. It's quick & easy.

Problem with character encoding in mail

P: 35
Hello!

I'm using a form to send a mail using PHP's mail() function. I'm having some trouble getting the character encoding just right. I need it to be in UTF-8 since i want Swedish characters allowed.

Setup is the following: the form is in UTF-8. The information is sent using an Ajax call to a php file that is encoded in UTF-8. Then, I send the mail with:
Expand|Select|Wrap|Line Numbers
  1. $header = "";
  2. $header .= "Reply-To: xxx <postmaster@".$_SERVER['SERVER_NAME'].">\r\n";
  3. $header .= "Return-Path: xxx <postmaster@".$_SERVER['SERVER_NAME'].">\r\n"; 
  4. $header .= "From: xxx <postmaster@".$_SERVER['SERVER_NAME'].">\r\n";
  5. $header .= "Organization: xxx \r\n"; 
  6. $header .= "Content-Type: text/plain; charset=utf-8\r\n";
  7.  
  8. $sent = mail("xxx", "Subject with Swedish chars", $message, $header);
Now, sending this to a gmail address works fine, no problems at all with the encoding. My work mail approves of it too (it puts it in quarantine but that's a later question :)), but Hotmail doesn't like it, it destroys the special characters in the "mail list" view.

Where am I going wrong? :)
Feb 24 '10 #1
Share this Question
Share on Google+
3 Replies


Dormilich
Expert Mod 5K+
P: 8,639
@brixton
nowhere, it seems a common problem that Hotmail doesn’t support UTF-8. you can either try to set the charset to UTF-8 manually or send the data converted in Latin-1.
Feb 24 '10 #2

P: 35
OK, thanks for the reply. I've been fiddling with utf8_encode / utf8_decode back and forth and this only screws up the result i Gmail and my work mail, so I think I'll accept the fact that Hotmail will mess it up (though it only does so in list view, not when viewing the full mail.

Another thing, using these headers my mail gets stuck in quarantine at my work mail. Can you see anything my header is lacking for it to get through that spam filter?
Feb 25 '10 #3

Dormilich
Expert Mod 5K+
P: 8,639
I think that’s nothing that can be easily fixed by something like changing a header (otherwise spammers would already have done that), although I’m not an expert in this field.
Feb 25 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.