Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Brak polskich znaków w wiadomości
d0m1n1k_
post
Post #1





Grupa: Zarejestrowani
Postów: 208
Pomógł: 3
Dołączył: 13.07.2009
Skąd: Tarnów

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


Witam,

zgodnie z tym co znalazłem na forum, poprawiłem skrypt mailowy (dodałem Content-type: text/html; charset=UTF-8)

  1. <?
  2.  
  3. // Replace this with your own email address
  4. $to="dominik@adddd.pl";
  5.  
  6. // Extract form contents
  7. $name = $_POST['name'];
  8. $email = $_POST['email'];
  9. $website = $_POST['website'];
  10. $subject = $_POST['subject'];
  11. $message = $_POST['message'];
  12.  
  13. // Validate email address
  14. function valid_email($str) {
  15. return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
  16. }
  17.  
  18. // Return errors if present
  19. $errors = "";
  20.  
  21. if($name =='') { $errors .= "name,"; }
  22. if(valid_email($email)==FALSE) { $errors .= "email,"; }
  23. if($message =='') { $errors .= "message,"; }
  24.  
  25. // Send email
  26. if($errors =='') {
  27.  
  28. $headers = "Content-type: text/html; charset=UTF-8 \r\n";
  29. $headers = 'Od: add <no-reply@add.com>'. "\r\n" .
  30. 'Reply-To: '.$email.'' . "\r\n" .
  31. 'X-Mailer: PHP/' . phpversion();
  32. $email_subject = "Website Contact Form: $email";
  33. $message="Wiadomosc od: $name \n\nEmail: $email \n\nWebsite: $website \n\nSubject: $subject \n\nMessage:\n\n $message";
  34.  
  35. mail($to, $email_subject, $message, $headers);
  36. echo "true";
  37.  
  38. } else {
  39. echo $errors;
  40. }
  41.  
  42. ?>



Tak czy tak, nadal niema polskich znaków tylko krzaczki i kwadraty.
Z góry dziękuję za pomoc (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
Tomplus
post
Post #2





Grupa: Zarejestrowani
Postów: 1 879
Pomógł: 230
Dołączył: 20.03.2005
Skąd: Będzin

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


Sprawdź w jakim kodowaniu jest wysyłana treść, pewnie nie jest to UTF-8, a jak coś możesz z konwertować tekst przy użyciu: iconv

Go to the top of the page
+Quote Post
d0m1n1k_
post
Post #3





Grupa: Zarejestrowani
Postów: 208
Pomógł: 3
Dołączył: 13.07.2009
Skąd: Tarnów

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


Poradziłem sobie.
Zmieniłem kolejność i zapisałem content w jednej $headers

  1. <?
  2.  
  3. // Replace this with your own email address
  4. $to="dominik@composix.pl";
  5.  
  6. // Extract form contents
  7. $name = $_POST['name'];
  8. $email = $_POST['email'];
  9. $website = $_POST['website'];
  10. $subject = $_POST['subject'];
  11. $message = $_POST['message'];
  12.  
  13. // Validate email address
  14. function valid_email($str) {
  15. return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
  16. }
  17.  
  18. // Return errors if present
  19. $errors = "";
  20.  
  21. if($name =='') { $errors .= "name,"; }
  22. if(valid_email($email)==FALSE) { $errors .= "email,"; }
  23. if($message =='') { $errors .= "message,"; }
  24.  
  25. // Send email
  26. if($errors =='') {
  27.  
  28. $headers = 'Od: FluidApp <no-reply@fluidapp.com>'. "\r\n" .
  29. 'Content-type: text/html; charset=UTF-8'. "\r\n".
  30. 'Reply-To: '.$email.'' . "\r\n" .
  31. 'X-Mailer: PHP/' . phpversion();
  32. $email_subject = "Website Contact Form: $email";
  33. $message="Wiadomosc od: $name \n\nEmail: $email \n\nWebsite: $website \n\nSubject: $subject \n\nMessage:\n\n $message";
  34.  
  35. mail($to, $email_subject, $message, $headers);
  36. echo "true";
  37.  
  38. } else {
  39. echo $errors;
  40. }
  41.  
  42. ?>
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 - 12:00