[PHP] Polskie znaki w temacie e-maila

0

Witam,
Napisałem kod do wysyłania e-maila w formacie HTML. Kodowanie treści listu doprowadziłem do porządku:

  <head>
    <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-2'>
  </head>

Jednak jeżeli w temacie listu znajdą się polskie znaczki w rezultacie zwracane są dziwne znaki (np. X jak wstawiam ł). Kod którym wysyłam mail'a:

<?php
  $naglowki = "From: Admin <[email protected]> \n"; 
  $naglowki .= "MIME-Version: 1.0\n";
  $naglowki .= "Content-type: text/html; charset=iso-8859-2\n";

  mail($email, "Nowe hasło", $wiadomosc, $naglowki);
?>

Czy da się w jakiś sposób wstawić polskie znaki diakrytyczne do tematu maila?
Pozdrawiam. :)

0

Jesli stosujesz utf-8 to np tak:

$headers['Subject'] = "=?utf-8?Q?".imap_8bit($subject)."?=";

Jesli fcja imap_8bit nie istnieje to :

if(!function_exists('imap_8bit')) {
function imap_8bit($text) {
return quoted_printable_encode($text);
}
}

function quoted_printable_encode_character ( $matches ) {
$character = $matches[0];
return sprintf ( '=%02x', ord ( $character ) );
}

  • based on http:*www.freesoft.org/CIE/RFC/1521/6.htm
    function quoted_printable_encode ( $string ) {
    // rule #2, #3 (leaves space and tab characters in tact)
    $string = preg_replace_callback (
    '/[^\x21-\x3C\x3E-\x7E\x09\x20]/',
    'quoted_printable_encode_character',
    $string
    );
    $newline = "=\r\n"; // '=' + CRLF (rule #4)
    // make sure the splitting of lines does not interfere with escaped characters
    // (chunk_split fails here)
    $string = preg_replace ( '/(.{73}[^=]{0,3})/', '$1'.$newline, $string);
    return $string;
    }// end func

Moze pomoze :)

0
Dedor napisał(a)

$headers['Subject'] = "=?utf-8?Q?".imap_8bit($subject)."?=";

<?
  $temat = "=?utf-8?Q?".imap_8bit('Nowe hasło')."?=";  

  mail($email, $temat, $wiadomosc, $naglowki);  
?>

Zrobiłem tak i działa jak trzeba. Wielkie dzięki za tą funkcję! [browar]

0

mozna tez:
$temat = "=?iso-8859-2?B?".base64_encode("temat z polskimi znakami")."?=";

1 użytkowników online, w tym zalogowanych: 0, gości: 1