mailclass

Status
Niet open voor verdere reacties.

pkmartijn

Gebruiker
Lid geworden
18 aug 2011
Berichten
163
ik heb een script:
PHP:
<?
class sendMail
{
    var $to;
    var $cc;
    var $bcc;
    var $subject;
    var $from;
    var $headers;
    var $html;

    function sendMail() 
    {
        $this->to       = NULL;
        $this->cc       = NULL;
        $this->bcc      = NULL;
        $this->subject  = NULL;
        $this->from     = NULL;
        $this->headers  = NULL;  
        $this->html     = FALSE;
    

    function getParams($params) 
    {
        $i = 0;
        foreach ($params as $key => $value) {
            switch($key) {
                case 'to':
                    $this->to       = $value;
                break;
                case 'cc':
                    $this->cc       = $value;
                break;
                case 'bcc':
                    $this->bcc       = $value;
                break;
                case 'subject':
                    $this->subject  = $value;
                break;
                case 'from':
                    $this->from     = $value;
                break;
                case 'submitted':
                    NULL;
                break;
                default:
                    $this->body[$i]["key"]     = str_replace("_", " ", ucWords(strToLower($key)));
                    $this->body[$i++]["value"] = $value;
            }
        }
    }

    function setHeaders() 
    {
        $this->headers = "From: $this->from\r\n";
        if($this->html === TRUE) {
            $this->headers.= "MIME-Version: 1.0\r\n";
            $this->headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
        }
        if(!empty($this->cc))  $this->headers.= "Cc: $this->cc\r\n";
        if(!empty($this->bcc)) $this->headers.= "Bcc: $this->bcc\r\n";
    }

    function parseBody() 
    {
        $count = count($this->body);
        for($i = 0; $i < $count; $i++) {
            if($this->html) $content.= "<b>";
            $content .= $this->body[$i]["key"].': ';
            if($this->html) $content.= "</b>";
            if($this->html) $content .= nl2br($this->body[$i]["value"])."\n";
            else $content .= $this->body[$i]["value"];
            if($this->html) $content.= "<hr noshade size=1>\n";
            else $content.= "\n".str_repeat("-", 80)."\n";
        }
        if($this->html) {
            $content = "
            <style>
                BODY {
                  font-family: verdana;
                  font-size: 10;
                }
            </style>
            ".$content;
        }
        $this->body = $content;
    }

    function send() 
    {
        if(mail($this->to, $this->subject, $this->body, $this->headers)) return TRUE;
        else return FALSE;
    }

    function set($key, $value) 
    {
        if($value) $this->$key = $value;
        else unset($this->$key);
    }
}
?>
maar hij geeft error op regel 101
weet iemand wat het is?
Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /public_html/martijn/mail/sendmail.class.php on line 101
 
ga eens {} tellen, ik denk dat je een } mis.
Om het je zelf makkelijker ttte maken, download netbeans(is gratis) en gebruik dat om te scripten.
Laat zien waar je mogelijke errors hebt en of je ; } ) vergeten bent.
Scheeld een stapel zoek en tel werk!
 
Een blik en ik zie dat er een } mist van de functie sendMail()

Volgens mij kun je die functie beter hernoemen naar __construct(), aangezien het volgens mij de bedoeling is dat dit uitgevoerd wordt wanneer de klasse geïnstancieerd wordt.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan