Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Skrypt do wysyłania powiadomien e-mail
mckpea
post 9.03.2016, 14:47:39
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 9.10.2012

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


witam, mam kod który ma wysyłać email z powiadomieniem, ale nie mogę sobie z nim poradzić cały czas skrypt wysyła mi w wiadomości warunki Content-Type w wew. wiadomości i ich nie interpretuje nie rozróżnia co jest text/plain a co text/html, załącznik wyświetlany jest w postaci binarnej, napewno coś robię źle tylko nie wiem co, proszę o pomoc oto kod:

  1.  
  2. <?php
  3.  
  4. $to = 'mymail@gmail.com';
  5.  
  6. $subject = 'Test.';
  7.  
  8. $random_hash = md5(time());
  9.  
  10. $headers = "From: Faktury \r\n Reply-To: księgowosc@domena.pl"."\r\n";
  11.  
  12. $headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\""."\r\n";
  13.  
  14. $headers .= "MIME-Version: 1.0"."\r\n";
  15.  
  16. $attachment = chunk_split(base64_encode(file_get_contents('plik.jpg')));
  17.  
  18. ?>
  19. --PHP-mixed-<?php echo $random_hash; ?>
  20. Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>"
  21.  
  22. --PHP-alt-<?php echo $random_hash; ?>
  23. Content-Type: text/plain; charset="iso-8859-1"
  24. Content-Transfer-Encoding: 7bit
  25.  
  26. Hello World!!!
  27. This is simple text email message.
  28.  
  29. --PHP-alt-<?php echo $random_hash; ?>
  30. Content-Type: text/html; charset="iso-8859-1"
  31. Content-Transfer-Encoding: 7bit
  32.  
  33. <h2>Hello World!</h2>
  34. <p>This is something with <b>HTML</b> formatting.</p>
  35.  
  36. --PHP-alt-<?php echo $random_hash; ?>--
  37.  
  38. --PHP-mixed-<?php echo $random_hash; ?>
  39. Content-Type: image/jpg; name="logo_notemaster.jpg"
  40. Content-Transfer-Encoding: base64
  41. Content-Disposition: attachment; filename="logo_notemaster.jpg"
  42.  
  43. <?php echo $attachment; ?>
  44. --PHP-mixed-<?php echo $random_hash; ?>--
  45.  
  46. <?php
  47.  
  48. $message = ob_get_clean();
  49.  
  50. $mail_sent = @mail( $to, $subject, $message, $headers );
  51.  
  52. echo $mail_sent ? "Mail sent" : "Mail failed";
  53. ?>
  54.  
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Wersja Lo-Fi Aktualny czas: 24.07.2025 - 16:33