Visualizzazione dei risultati da 1 a 5 su 5

Discussione: class.SimpleMail.php

  1. #1

    class.SimpleMail.php

    Sto provando un'applicazione per creare una mailing list. Ho scaricato degli script on-line ed è andato tutto abbastanza bene fino allo script di invio, class.SimpleMail.php:


    <?php

    class SimpleMail {
    public $to = NULL;
    public $cc = NULL;
    public $bcc = NULL;
    public $from = NULL;
    public $subject = '';
    public $body = '';
    public $htmlbody = '';
    public $send_text = TRUE;
    public $send_html = FALSE;
    private $message = '';
    private $headers = '';

    public function send($to = NULL,
    $subject = NULL,
    $message = NULL,
    $headers = NULL) {
    if (func_num_args() >= 3) {
    $this->to = $to;
    $this->subject = $subject;
    $this->message = $message;
    if ($headers) {
    $this->headers = $headers;
    }

    } else {

    eccetera........


    che mi segnala questo errore qui:

    Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /class.SimpleMail.php on line 3



    Qualcuno mi può dare una mano? O suggerire una soluzione più semplice?



  2. #2
    vedo 3 parentesi graffe aperte e solo 2 chiuse.. prima dell'else..

    toglilo su questa riga: $headers = NULL) {

  3. #3
    Utente di HTML.it L'avatar di luca200
    Registrato dal
    Apr 2002
    Messaggi
    4,120
    Usi PHP4?
    Quella classe è per PHP5

  4. #4
    Per davidino80.

    "vedo 3 parentesi graffe aperte e solo 2 chiuse.. prima dell'else..

    toglilo su questa riga: $headers = NULL) { ".



    Ho provato a cancellare quella parentesi ma mi dà sempre lo stesso errore. Dopo l'else si richiudono tutte.

  5. #5
    Per Luca200.


    Si io uso PHP4 e questa è una classe per PHP5. Per questa mailing list il libro che seguo fa ricorso a PHP5. Ci deve essere qualche errore di stampa perchè tutti gli altri script del libro sono giusti. Ti posto l'intero script, puoi controllarlo per me? Grazie


    <?php

    class SimpleMail {
    public $to = NULL;
    public $cc = NULL;
    public $bcc = NULL;
    public $from = NULL;
    public $subject = '';
    public $body = '';
    public $htmlbody = '';
    public $send_text = TRUE;
    public $send_html = FALSE;
    private $message = '';
    private $headers = '';

    public function send($to = NULL,
    $subject = NULL,
    $message = NULL,
    $headers = NULL) {
    if (func_num_args() >= 3) {
    $this->to = $to;
    $this->subject = $subject;
    $this->message = $message;
    if ($headers) {
    $this->headers = $headers;
    }

    } else {

    if ($this->from) {
    $this->headers .= "From: " . $this->from . "\r\n";
    }
    if ($this->cc) {
    $this->headers .= "Cc: " . $this->cc . "\r\n";
    }
    if ($this->bcc) {
    $this->headers .= "Bcc: " . $this->bcc . "\r\n";
    }

    if ($this->send_text and !$this->send_html) {
    $this->message = $this->body;
    } elseif ($this->send_html and !$this->send_text) {
    $this->message = $this->htmlbody;
    $this->headers .= "MIME-Version: 1.0\r\n";
    $this->headers .= "Content-type: text/html; " .
    "charset=iso-8859-1\r\n";
    } else {
    $_boundary = "==MP_Bound_xyccr948x==";

    $this->headers = "MIME-Version: 1.0\r\n";
    $this->headers .= "Content-type: multipart/alternative; " .
    "boundary=\"$_boundary\"\r\n";

    $this->message = "This is a Multipart Message in " .
    "MIME format\n";
    $this->message .= "--$_boundary\n";
    $this->message .= "Content-Type: text/plain; " .
    "charset=\"iso-8859-1\"\n";
    $this->message .= "Content-Transfer-Encoding: 7bit\n\n";
    $this->message .= $this->body . "\n";
    $this->message .= "--$_boundary\n";
    $this->message .= "Content-type: text/html; " .
    "charset=\"iso-8859-1\"\n";
    $this->message .= "Content-Transfer-Encoding: 7bit\n\n";
    $this->message .= $this->htmlbody . "\n";
    $this->message .= "--$_boundary--";
    }
    }

    if (!mail($this->to,$this->subject,$this->message,$this->headers)) {
    throw new Exception('Sending mail failed.');
    return FALSE;
    } else {
    return TRUE;
    }
    }

    }

    ?>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.