I try to send mails in other language then english, lets say french there are special characters, I'm making test with mail function from php but I cant get to send a clear mail...

In gmail and outlook I receive the email ok but in yahoo the characters are not interpreted corectly, does anyone know how to set the mail function headers or encode the message so it will be sent OK to all type of mail clients.

Ex. of word sent: Téléphones
How do I receive it in yahoo: Téléphones

    Are you sending the note as text or as html? You could htmlspecialchars() your output for starters. I think if you search on mail header in this forum you will find alot of examples how people do this...

      You need to ensure that the email has whatever MIME headers are necessary to indicate the encoding you're using.

      Otherwise, the mail client will have to guess and will probably get it wrong.

      Hint: Add a Content-type header to the mail

      Mark

        MarkR wrote:

        You need to ensure that the email has whatever MIME headers are necessary to indicate the encoding you're using.

        Otherwise, the mail client will have to guess and will probably get it wrong.

        Hint: Add a Content-type header to the mail

        Mark

        This are the headers I'm using ...

        From: \"domain\"  <mail@domain>
        MIME-Version: 1.0
        Content-type: text/html; charset=iso-8859-1
        X-Priority: 1

        I have tried UTF-8 but the same result:

        Content-type: text/html; charset=UTF-8

        I have tried even to encode the subject and message with utf8_encode(), but no success. 🙁

        Thank you both for your answers.

          Please post the RAW mail message (complete with all headers, unaltered, as it was sent) as an attachment.

          Also tell us what encoding you're using in your app. Currently you seem to be groping in the dark to find the right encoding.

          You should not do that.

          It looks somewhat as if you've had some characters transformed from latin1 to utf-8 more times than they should have been. This could be because there are inconsistencies in the way your application as a whole is using encodings.

          Mark

            Here is my little example:

            $to = "my_email_address@yahoo.com";
            $subject = "Téléphones";
            $message = "Téléphones";
            $header = "From: \"domain\"  <mail@domain>\r\n";
            $header.= "MIME-Version: 1.0\r\n";
            $header.= "Content-type: text/html; charset=iso-8859-1\r\n";
            $header.= "X-Priority: 1\r\n";
            @mail($to,$subject,$message,$header);

              Well it is not the best solution but it will work and that is to use HTML for those characters like T&eacute;l&eacute;phone
              but then you would have to have access to all those special characters, but with my editor I do have them and they will send them all except for the subject. They only work of course in HTML mail which in your example code that is what you are using, while it might be a pain it is garunteed to work.

                As Houdini said, since you're sending HTML mail, you might try using [man]htmlentities/man to convert the special characters to HTML-safe codes.

                  Houdini wrote:

                  Well it is not the best solution but it will work and that is to use HTML for those characters like T&eacute;l&eacute;phone
                  but then you would have to have access to all those special characters, but with my editor I do have them and they will send them all except for the subject. They only work of course in HTML mail which in your example code that is what you are using, while it might be a pain it is garunteed to work.

                  The problem is that I send both type of emails text/plain and text/html, and in the project are lots of email ...
                  I just change the site to multilanguage and I have problem with emails sent to some of the mail clients one of them is yahoo, gmail and outlook works grate ..

                    Oh I see, at least it was a thought, at least the email that is HTML would render correctly, but problably not worth all the extra effort.

                      Hmm.

                      Okay, you said you tried UTF8? Is this what you tried?

                      $to = "my_email_address@yahoo.com"; 
                      $subject = "Téléphones"; 
                      $message = "Téléphones"; 
                      $header = "From: \"domain\"  <mail@domain>\r\n"; 
                      $header.= "MIME-Version: 1.0\r\n"; 
                      $header.= "Content-type: text/html; charset=utf-8\r\n"; 
                      $header.= "X-Priority: 1\r\n"; 
                      @mail($to,utf8_encode($subject),utf8_encode($message),$header); 

                      EDIT: If that doesn't work, try this:

                      $to = "my_email_address@yahoo.com"; 
                      $subject = "Téléphones"; 
                      $message = "Téléphones"; 
                      $header = "From: \"domain\"  <mail@domain>\r\n"; 
                      $header.= "MIME-Version: 1.0\r\n"; 
                      $header.= "Content-type: text/html; charset=iso-8859-1\r\n"; 
                      $header.= "X-Priority: 1\r\n"; 
                      @mail($to,utf8_decode($subject),utf8_decode($message),$header);

                        Nice 😃 , the last one I didnt try it, but first thing in the morrning I'll do, now I'm to tired to keep my eyes open, write u tomorow if it works ... 😃

                          12 years later

                          <?php

                          $recipient = "mymail@domain.pl";
                          $name = $POST['nameeval'];
                          $email = $
                          POST['emaileval'];
                          $message = $_POST['messageeval'];

                          if (isset($_POST['emaileval'])) {

                          $ip = getenv('REMOTE_ADDR');
                          $host = gethostbyaddr($ip);
                          $mess = "Name: ".$name."\n";
                          $mess .= "Email: ".$email."\n";

                          $mess .= "IP:".$ip." HOST: ".$host."\n";


                          $headers = "From: <".$email.">\r\n";
                          $headers = "Wiadomość: <".$message.">\r\n";

                           if(isset($_POST['url']) && $_POST['url'] == ''){
                          
                             $sent = mail ($recipient, $mess, $headers); 

                          }


                          } else {
                          die('Invalid entry!');
                          }
                          ?>

                          I've got the same problem in outlook 2016. Trying to encode it, but nothing happen. Maybe someone can help?

                            Write a Reply...