umlaut in mail sent by php?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oliver Spiesshofer

    #1

    umlaut in mail sent by php?

    Hi,

    I am trying to send emails with the php Mail function, but umlaut and other
    special characters are not displayed correctly. Actually they are replaced
    by large X's. I checked if there is an error on the receiving side, but
    both thunderbird and squirrelmail do the same!

    any Idea what is wrong? do I have to make a mb_string_recod e? but to what
    charset?

    The emails are sent in UTF-8 encoding, and the umlaute in the email body
    display just perfectly!

    Oliver

  • Philip Ronan

    #2
    Re: umlaut in mail sent by php?

    Oliver Spiesshofer wrote:
    [color=blue]
    > Hi,
    >
    > I am trying to send emails with the php Mail function, but umlaut and other
    > special characters are not displayed correctly. Actually they are replaced
    > by large X's. I checked if there is an error on the receiving side, but
    > both thunderbird and squirrelmail do the same!
    >
    > any Idea what is wrong? do I have to make a mb_string_recod e? but to what
    > charset?
    >
    > The emails are sent in UTF-8 encoding, and the umlaute in the email body
    > display just perfectly!
    >
    > Oliver[/color]

    Are you saying they appear correctly in the email body, but not in the
    headers (subject, etc.)?

    I think internet headers have to be sent as 7-bit data. To send non-ASCII
    characters you have to use an "encoded word" as defined in RFC 2047. For
    example, "München" can be encoded like this:

    =?iso-8859-1?q?M=FCnchen?=

    Obviously that uses iso-8859-1 encoding, but you get the picture.

    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    PHILIP A. RONAN
    Freelance Japanese Translator
    205 Hamlin Lane, Exeter EX1 2SQ, England
    Tel/Fax: +44 (0) 1392 435019
    Email: mail@japanesetr anslator.co.uk

    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

    Comment

    • NC

      #3
      Re: umlaut in mail sent by php?

      Oliver Spiesshofer wrote:[color=blue]
      >
      > I am trying to send emails with the php Mail function, but
      > umlaut and other special characters are not displayed correctly.
      > Actually they are replaced by large X's. I checked if there
      > is an error on the receiving side, but both thunderbird and
      > squirrelmail do the same!
      >
      > any Idea what is wrong?[/color]

      Try this:

      $subject = mb_convert_enco ding($subject, 'ISO-8859-1', 'UTF-8');

      And make sure you have this header:

      Content-Transfer-Encoding: 8 bit

      Cheers,
      NC

      Comment

      • Oliver Spiesshofer

        #4
        Re: umlaut in mail sent by php?

        "NC" <nc@iname.com > wrote in news:1109354489 .489314.276270
        @g14g2000cwa.go oglegroups.com:
        [color=blue]
        > $subject = mb_convert_enco ding($subject, 'ISO-8859-1', 'UTF-8');[/color]

        thats what I did now.
        Hoever, it still does not arrive in the end properly.
        Here is the part of my headers:

        Content-Type: text/html; charset=utf-8
        Content-Transfer-Encoding: 8bit
        Subject: Berliner Techno-Club Tresor schlieXt nach 15 Jahren

        The script which is doing it now produces a logfile, and the title in the
        logfile is correct! If I use ASCII instead of ISO as an encoding, I get a ?
        instead of a X for invalid letters....

        any other ideas what I could do?

        Oliver


        Comment

        • Philip Ronan

          #5
          Re: umlaut in mail sent by php?

          Oliver Spiesshofer wrote:
          [color=blue][color=green]
          >> $subject = mb_convert_enco ding($subject, 'ISO-8859-1', 'UTF-8');[/color]
          >
          > thats what I did now.
          > Hoever, it still does not arrive in the end properly.
          > Here is the part of my headers:
          >
          > Content-Type: text/html; charset=utf-8
          > Content-Transfer-Encoding: 8bit
          > Subject: Berliner Techno-Club Tresor schlieXt nach 15 Jahren[/color]

          That's because you're putting 8-bit data in a mail header. Mail headers can
          only contain 7-bit data. I mentioned that already.
          [color=blue]
          > The script which is doing it now produces a logfile, and the title in the
          > logfile is correct! If I use ASCII instead of ISO as an encoding, I get a ?
          > instead of a X for invalid letters....[/color]

          That's because there is no umlaut in the ASCII character set
          [color=blue]
          > any other ideas what I could do?[/color]

          1. Read RFC 2047
          2. Read my last post in this thread

          --
          phil [dot] ronan @ virgin [dot] net



          Comment

          • Manuel Lemos

            #6
            Re: umlaut in mail sent by php?

            Hello,

            on 02/25/2005 08:51 AM Oliver Spiesshofer said the following:[color=blue]
            > I am trying to send emails with the php Mail function, but umlaut and other
            > special characters are not displayed correctly. Actually they are replaced
            > by large X's. I checked if there is an error on the receiving side, but
            > both thunderbird and squirrelmail do the same!
            >
            > any Idea what is wrong? do I have to make a mb_string_recod e? but to what
            > charset?
            >
            > The emails are sent in UTF-8 encoding, and the umlaute in the email body
            > display just perfectly![/color]

            You do not need to encode in UTF. You just need to encode with
            quoted-printable for characters in the body and q-encoding for
            characters in the headers.

            Take a look at this class can can encode and send messages properly and
            even comes with an example of how to send messages with accents:

            http://www.phpclasses.org/mimemessage


            --

            Regards,
            Manuel Lemos

            PHP Classes - Free ready to use OOP components written in PHP
            http://www.phpclasses.org/

            PHP Reviews - Reviews of PHP books and other products
            http://www.phpclasses.org/reviews/

            Metastorage - Data object relational mapping layer generator

            Comment

            • Oliver Spiesshofer

              #7
              Re: umlaut in mail sent by php?

              Philip Ronan <invalid@invali d.invalid> wrote in
              news:BE467201.2 C022%invalid@in valid.invalid:
              [color=blue]
              > 1. Read RFC 2047
              > 2. Read my last post in this thread[/color]

              thanks. I got now what you meant.

              I found the (IMHO) easiest way to deal with it.
              I simply run the subject through a mb_encode_mimeh eader().

              This worked very nicely.

              Oliver


              Comment

              Working...