PHP Email for other languages

Discussion in 'PHP' started by Ankit, Feb 3, 2009.

  1. #1
    I am trying to convert email into UTF-8 and using below function.

    ### FOR EMAIL
    function imap8bit(&$item, $key) {
    $item = imap_8bit($item);
    }

    function email($e_mail, $subject, $message, $headers)
    {
    // add headers for utf-8 message
    $headers .= "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/plain; charset=utf-8\r\n";
    $headers .= "Content-Transfer-Encoding: quoted-printable\r\n";

    // encode subject
    //=?UTF-8?Q?encoded_text?=

    // work a round: for subject with wordwrap
    // not fixed, no possibility to have one in a single char
    $subject = wordwrap($subject, 25, "\n", FALSE);
    $subject = explode("\n", $subject);
    array_walk($subject, imap8bit);
    $subject = implode("\r\n ", $subject);
    $subject = "=?UTF-8?Q?".$subject."?=";
    $subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";

    // encode e-mail message
    $message = imap_8bit($message);

    return(mail("$e_mail", "$subject", "$message", "$headers"));
    }
    ### FOR EMAIL

    everything is working correctly. but subject shows

    values like =D8=B9=D9=84=D9=89 =D8=A3=D8=AC=D9=88=D8=A7=D8=A1 =D8=B4=D9=88=D8=A7=D8=B7=D8=A6

    Please help

    Post If any other function works.
     
    Ankit, Feb 3, 2009 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    it is because of the array_walk
    what do you want with your subject?
     
    bartolay13, Feb 3, 2009 IP