Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] wysylanie maila, mail przez php
gojira
post
Post #1





Grupa: Zarejestrowani
Postów: 48
Pomógł: 0
Dołączył: 14.10.2007

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


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
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
Glarden
post
Post #2





Grupa: Zarejestrowani
Postów: 153
Pomógł: 2
Dołączył: 28.05.2007
Skąd: Stamtąd

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


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.
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: 22.08.2025 - 23:56