Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php] wysylanie maila
Forum PHP.pl > Forum > Przedszkole
gojira
otoz chcialem wyslac maila z moje strony. utworzylem sobie kod i raczej powinien dzialac, jednak nie wysyla maila...

  1. <?php
  2. function send_mail($emailaddress, $emailsubject, $body, $fromaddress){
  3. $eol="r\n";
  4. $mime_boundary=md5(time());
  5.  
  6. # Common Headers
  7. $headers .= 'From: MyName<'.$fromaddress.'>'.$eol;
  8. $headers .= 'Reply-To: MyName<'.$fromaddress.'>'.$eol;
  9. $headers .= 'Return-Path: MyName<'.$fromaddress.'>'.$eol;
  10. $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
  11. $headers .= "X-Mailer: PHP v".phpversion().$eol;
  12.  
  13. # Boundry for marking the split & Multitype Headers
  14. $headers .= 'MIME-Version: 1.0'.$eol;
  15. $headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
  16.  
  17. $msg = "";
  18.  
  19. # Setup for text OR html
  20. $msg .= "Content-Type: multipart/alternative".$eol;
  21.  
  22. # Text Version
  23. $msg .= "--".$mime_boundary.$eol;
  24. $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
  25. $msg .= "Content-Transfer-Encoding: 8bit".$eol;
  26. $msg .= strip_tags(str_replace("<br>", "\n", $body)).$eol.$eol;
  27.  
  28. # HTML Version
  29. $msg .= "--".$mime_boundary.$eol;
  30. $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
  31. $msg .= "Content-Transfer-Encoding: 8bit".$eol;
  32. $msg .= $body.$eol.$eol;
  33.  
  34. # Finished
  35. $msg .= "--".$mime_boundary."--".$eol.$eol; 
  36.  
  37. # SEND THE EMAIL
  38. ini_set(sendmail_from,$fromaddress);
  39. mail($emailaddress, $emailsubject, $msg, $headers);
  40. ini_restore(sendmail_from);
  41. echo "mail send";
  42. }
  43.  
  44.  
  45. # To Email Address
  46. $emailaddress=$email;
  47.  
  48. # From Email Address
  49. $fromaddress = "mm@mm.pl";
  50.  
  51. # Message Subject
  52. $emailsubject="Zamowienie zrealizowane.";
  53.  
  54.  
  55. # Message Body
  56. $body="Zakupione przez Panstwa produkty zostana wyslane w przeciagu 2 tygodni.</br>
  57. Prosze o potwierdzenie zamowienia";
  58.  
  59. send_mail($emailaddress, $emailsubject, $body, $fromaddress);
  60. ?>


jezeli widzicie gdzie popelnilem blad bylbym wdzieczny za wskazanie

pozdrawiam
Glarden
Może nie masz czegoś tam ustawionego (nie pamiętam, gdzie to się robi, ale to częsty błąd przy wysyłaniu maili)? Wypróbuj klasę PHPMailer albo powiedz chociaż, czy wywala jakiś błąd.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.