Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP5] Problem z klasą wysyłającą email
Forum PHP.pl > Forum > PHP
graft
Mam oto taki problem:


Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/id1532/public_html/moja_strona/includes/class.simple_mail.php on line 5


natomiast w lini piątej znajduje się:

  1. <?php
  2. public $to = NULL; //jest to jedna linijka słynnej klasy Classs_simple.mail.php z książki Beginning P
    HP, Apache, MySQL Web Development
  3. ?>



Mam plik sprawdzający użytkowników (wywołuję przy pomocy CRON'a) i np. jeśli nie logowali się 3 m-ce ma im wysłać maila z przypomnieniem.
Jeśli uruchomię plik ręcznie - wtedy działa blinksmiley.gif

Ma ktoś sposób jak to odpalić?
A może zaproponujecie lepszą klasę do wysyłania maila (w mailu przychodzącym musi być tekst HTML i niewielkie logo)?
mike
To móże pokażesz tą klasę tongue.gif
Zawsze dawaj więcej kodu, inż jedna linia. W wielu przypadkach, w tym podobnie, błąd jest gdzieś indziej.
graft
Proszę bardzo:

  1. <?php
  2.  
  3. class SimpleMail {
  4.  
  5. public $to = NULL;  // <--- 5 linijka
  6. public $cc = NULL;
  7. public $bcc = NULL;
  8. public $from = NULL;
  9. public $subject = '';
  10. public $body = '';
  11. public $htmlbody = '';
  12. public $send_text = TRUE;
  13. public $send_html = FALSE;
  14. private $message = '';
  15. private $headers = '';
  16.  
  17. public function send($to = NULL,
  18.  $subject = NULL,
  19.  $message = NULL,
  20.  $headers = NULL) {
  21. if (func_num_args() >=3) {
  22. $this->to = $to;
  23. $this->subject = $subject;
  24. $this->message = $message;
  25. if ($headers) {
  26. $this->headers = $headers;
  27. }
  28. } else {
  29.  
  30. if ($this->from) {
  31. $this->headers .= "From: " . $this->from . "r\n";
  32. }
  33. if ($this->cc) {
  34. $this->headers .= "Cc: " . $this->cc . "r\n";
  35. }
  36. if ($this->bcc) {
  37. $this->headers .= "Bcc: " . $this->bcc . "r\n";
  38. }
  39.  
  40. if ($this->send_text and !$this->send_html) {
  41. $this->message = $this->body;
  42. } elseif ($this->send_html and !$this->send_text) {
  43. $this->message = $this->htmlbody;
  44. $this->headers .= "MIME-Version: 1.0r\n";
  45. $this->headers .= "Content-type: text/html; " . "charset=iso8859-2r\n";
  46. $this->headers .= "Content-ID: <logobg_m.jpg>r\n";
  47. } else {
  48. $_boundary = "==MP_Bound_xyccr948x==";
  49.  
  50. $this->headers = "MIME-Version: 1.0r\n";
  51. $this->headers .= "Content-type: multipart/alternative; " . "boundary=\"$_boundary\"r\n";
  52.  
  53. $this->message = "Message (MIME format\n)";
  54. $this->message .= "--$_boundary\n";
  55. $this->message .= "Content-type: text/plain; " . "charset=\"iso8859-2\"\n"; 
  56. $this->message .= "Content-Transfer-Encoding: 8bit\n\n";
  57. $this->message .= $this->body . "\n";
  58. $this->message .= "--$_boundary\n";
  59. $this->message .= "Content-type: text/plain; " . "charset=\"iso8859-2\"\n";
  60. $this->message .= "Content-Transfer-Encoding: 8bit\n\n";
  61. $this->message .= $this->htmlbody . "\n";
  62. $this->message .= "--$_boundary--";
  63. }
  64. }
  65. if (!mail($this->to,$this->subject,$this->message,$this->headers)) {
  66. throw new Exception('Send message - Error.');
  67. return FALSE;
  68. }else{
  69. return TRUE;
  70. }
  71. }
  72. }
  73. ?>
phpion
Może na serwerze jest PHP4?
graft
Mam konto na AZ.pl. Tak jak pisałem, przy ręcznym wywołaniu pliku www.mojastrona.pl/nazwa_pliku.php email jest wysyłany. Natomiast gdy ustawię CRON'a pojawia się ten błąd worriedsmiley.gif
mike
To zonacza że podczas wywyołania z Cron'a system korzysta ze starej wersji PHP.
Nic nie poradzisz, czeka Cię wycieczka do admina.
graft
No ok, wracam do problemu:
Spece napisali mi że mam użyć przed komendą "bezpośrednią ścieżkę do interpretera php5":

/usr/local/php5/bin/php


Zastosowałem i mam obecnie taką komendę:

/usr/local/php5/bin/php -q /home/id234123/public_html/moj_katalog/plik.php5

Nie działa to jednak. Otrzymuję w wyniku: /bin/sh: /usr/local/php5/bin: No such file or directory


Jedyne co mi przychodzi do głowy to pozbycie się /bin/sh worriedsmiley.gif

Ale jak questionmark.gifquestionmark.gif?
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.