Problem with character encoding in mail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brixton
    New Member
    • Nov 2006
    • 35

    Problem with character encoding in mail

    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:
    Code:
    $header = "";
    $header .= "Reply-To: xxx <postmaster@".$_SERVER['SERVER_NAME'].">\r\n";
    $header .= "Return-Path: xxx <postmaster@".$_SERVER['SERVER_NAME'].">\r\n"; 
    $header .= "From: xxx <postmaster@".$_SERVER['SERVER_NAME'].">\r\n";
    $header .= "Organization: xxx \r\n"; 
    $header .= "Content-Type: text/plain; charset=utf-8\r\n";
    
    $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? :)
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Originally posted by brixton
    Where am I going wrong? :)
    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.

    Comment

    • brixton
      New Member
      • Nov 2006
      • 35

      #3
      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?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        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.

        Comment

        Working...