Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Brak polskich liter w tytule maila - phpmailer, ustawione charset na utf-8
Agape
post
Post #1





Grupa: Zarejestrowani
Postów: 384
Pomógł: 13
Dołączył: 16.06.2006

Ostrzeżenie: (0%)
-----


W tytule maila nie mam polskich znaków w treści one są. Obydwie zmienne są stałe, wysyłane z kodu PHP. To kawałek kodu którym wysyłam maila:
  1. function wyslij_mail($tytul, $m_wiadomosc){
  2. $mail->CharSet="utf-8";
  3. require('funkcje/class.phpmailer.php');
  4. $mail = new PHPMailer();
  5. $mail->PluginDir = "phpmailer/";
  6. $mail->From = "***@gmail.com";
  7. $mail->FromName = "***";
  8. $mail->Host = "ssl://smtp.gmail.com:465";
  9. $mail->Mailer = "smtp";
  10. $mail->Username = "***";
  11. $mail->Password = "***";
  12. $mail->SMTPAuth = true;
  13. $mail->SetLanguage("pl", "phpmailer/language/");
  14.  
  15. $mail->Subject = $tytul;
  16. $mail->IsHTML(true);
  17. $mail->Body = $m_wiadomosc;
  18. $mail->AddAddress("***@gmail.com","***");


Co więc mogę zrobić skoro kodowanie utf-8 jest już ustawione :|
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
mortus
post
Post #2





Grupa: Zarejestrowani
Postów: 2 178
Pomógł: 596
Dołączył: 25.09.2009
Skąd: Piwniczna-Zdrój

Ostrzeżenie: (0%)
-----


Witam.
Jest to znany bug phpMailer-a. Aby usunąć problem (z tego co się orientuje nie został on rozwiązany w nowej wersji biblioteki), należy ściągnąć patch encoding.patch lub utf8_encoding.patch i uaktualnić plik class.phpmailer.php. W systemach unix-owych służy do tego polecenie
Kod
patch -b class.phpmailer.php utf8_encoding.patch
Nie wiem, czy istnieje windows-owy odpowiednik tego polecenia.
Pozdrawiam
Go to the top of the page
+Quote Post
Agape
post
Post #3





Grupa: Zarejestrowani
Postów: 384
Pomógł: 13
Dołączył: 16.06.2006

Ostrzeżenie: (0%)
-----


Słaby jestem jeśli chodzi o linuxy ;/
Cytat
$ patch -b class.phpmailer.php utf8_encoding.patch
patching file class.phpmailer.php
Reversed (or previously applied) patch detected! Assume -R? [n]
Apply anyway? [n] y
Hunk #1 FAILED at 933.
Hunk #2 FAILED at 954.
Hunk #3 FAILED at 972.
Hunk #4 succeeded at 1010 with fuzz 2 (offset 248 lines).
Hunk #5 FAILED at 1496.
Hunk #6 FAILED at 1519.
5 out of 6 hunks FAILED -- saving rejects to file class.phpmailer.php.rej


a drugi raz jak wziąłem odrazu y

Cytat
$ patch -b class.phpmailer.php utf8_encoding.patch
patching file class.phpmailer.php
Reversed (or previously applied) patch detected! Assume -R? [n] y
Hunk #1 succeeded at 933 with fuzz 2 (offset 241 lines).
Hunk #2 FAILED at 951.
Hunk #3 FAILED at 967.
Hunk #4 succeeded at 996 with fuzz 2 (offset 241 lines).
Hunk #5 FAILED at 1423.
Hunk #6 FAILED at 1440.
4 out of 6 hunks FAILED -- saving rejects to file class.phpmailer.php.rej


Ten post edytował Agape 12.04.2010, 09:48:17
Go to the top of the page
+Quote Post
athei
post
Post #4





Grupa: Zarejestrowani
Postów: 389
Pomógł: 141
Dołączył: 11.04.2009

Ostrzeżenie: (0%)
-----


Z najnowszym phpmailer (11.2009, http://sourceforge.net/projects/phpmailer/...0for%20php5_6/) nie ma żadnych problemów z polskimi znakami. A ten patch już jest dodany. Może klient pocztowy ma problemy z utf8? TB/gmail www wszystko działa.
Kod którego używałem
  1. <?php
  2. require_once 'class.phpmailer.php';
  3. require_once 'class.smtp.php';
  4.  
  5. $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
  6. $mail->IsSMTP(); // telling the class to use SMTP
  7. try {
  8. $mail->SMTPAuth = true; // enable SMTP authentication
  9. $mail->SMTPSecure = "ssl"; // sets the prefix to the servier
  10. $mail->Host = "smtp.gmail.com"; // SMTP server
  11. $mail->Port = 465; // set the SMTP port
  12. $mail->Username = "ABCDE@gmail.com"; // SMTP account username
  13. $mail->Password = "haslo"; // SMTP account password
  14. $mail->SetFrom('ABCDE@gmail.com', 'ABCDE');
  15. $mail->AddAddress('dokogo@gmail.com', 'XYZ');
  16. $mail->Subject = 'ŁÓDŹ ąśćźńół';
  17. $mail->Body = 'ŁÓDŹ ąśćźńół';
  18. $mail->SetLanguage('pl', 'language/');
  19. $mail->CharSet = 'utf-8';
  20. $mail->IsHTML(false);
  21. $mail->WordWrap = 100;
  22. /**
  23.   * Gdy HTML
  24.   * $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  25.   * $mail->MsgHTML($body);
  26.   * $mail->MsgHTML(file_get_contents('contents.html'));
  27.   */
  28. /*
  29.  // Załączniki
  30.   $mail->AddAttachment("images/phpmailer.gif"); // attachment
  31.   $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
  32. */
  33.  
  34. $mail->Send();
  35. echo "Wiadomość wysłana!\n";
  36. } catch (phpmailerException $e) {
  37. echo $e->errorMessage(); //Error od Phpmailer
  38. } catch (Exception $e) {
  39. echo $e->getMessage(); //Inny error
  40. }
  41.  
  42. ?>


Go to the top of the page
+Quote Post
Agape
post
Post #5





Grupa: Zarejestrowani
Postów: 384
Pomógł: 13
Dołączył: 16.06.2006

Ostrzeżenie: (0%)
-----


Okazało się, że
  1. $mail->CharSet = 'utf-8';

miałem za wcześnie. Ustawiłem na koniec i hula. Dzięki.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 04:23