[UPDATE 26.7.07] PHP Mailerclass mit Massenmailfunktion und MailBB-Code

Diskutiere und helfe bei [UPDATE 26.7.07] PHP Mailerclass mit Massenmailfunktion und MailBB-Code im Bereich Webmaster Support, Scripts, etc im SysProfile Forum bei einer Lösung; Habe hier mit nem Kumpel eine kleine PHP-Class geschrieben. Hoffe, die gefällt euch und findet Anklang. Sie beschreibt sich selbst im Code ;) <?php... Discussion in 'Webmaster Support, Scripts, etc' started by Spacerat, Jul 24, 2007.

  1. Spacerat
    Spacerat ٩(̾●̮̮̃̾•̃̾)۶ /dev/null
    Joined:
    Dec 25, 2006
    Messages:
    8,597
    Likes Received:
    196
    Name:
    Christian
    1. SysProfile:
    11226
    Steam-ID:
    Spacerat2911

    Habe hier mit nem Kumpel eine kleine PHP-Class geschrieben. Hoffe, die gefällt euch und findet Anklang. Sie beschreibt sich selbst im Code ;)

    PHP:
    <?php
    #################################################
    ##
    ##
    ##        BBCode Supporting E-Mail Class
    ##        with massmail function
    ##
    ##        Author: SynN and fanrpg (c) 2007
    ##        Date: 07/23/07
    ##
    ##        Version: 1.0.0
    ##        
    ##        Licensed under GNU Public License
    ##        http://opensource.org/licenses/gpl-license.php
    ##
    ##
    #################################################

    #################################################
    ##
    ##        Example:
    ##        
    ##        $mail = new Email();
    ##
    ##        $mail->set("from", "absender@example.com");
    ##        $mail->set("to", "empfaenger@example.com"); // You can use mto to send massmail ( $mail->set("mto", array("mail@example.com", "mail2@example.com")) )
    ##        $mail->set("subject", "Betreff"); // Subject for mail
    ##        $mail->set("html", 1) // html email 1 = on, 0 = off
    ##        $mail->set("mailbb", 1) // bbcode for mails 1 = on, 0 = off
    ##        $mail->set("message", "Message of the Mail");
    ##        $mail->send();
    ##        $mail->clean();
    ##
    ##        Optional commands:
    ##
    ##        $mail->set("header", "own header"); // to set own header..
    ##        $mail->set("bcc", "bcc@example.com"); // to send a blindcopy
    ##        $mail->set("cc", "cc@example.com"); // to send a copy
    ##
    ##        You can use mbcc, mcc to send mass bcc or cc, like to use mto.
    ##        You can also combine to and mto, cc and mcc, bcc and mbcc and all of them with arrays or just strings.
    ##
    #################################################

    class Email
    {
        var 
    $from;
        var 
    $to;
        var 
    $subject;
        var 
    $headers;
        var 
    $bcc;
        var 
    $cc;
        var 
    $message;
        var 
    $mailbb;
        var 
    $html false;
        var 
    $send false;
        
        
        function 
    set($type$value)
        {
            switch( 
    $type )
            {
                case 
    'html':
                    if( 
    $value == or $value === true )
                    {
                        
    $this->html true;
                        
    $this->set("header""Content-Type: text/html");
                        
    $this->set("header""Content-Transfer-Encoding: 8bit");
                    }
                    break;
                case 
    'from':
                    if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$value) )
                    {
                        
    $this->from $value;
                    }
                    else
                    {
                        return 
    false;
                    }
                    break;
                case 
    'to':
                    if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$value) )
                    {
                        
    $this->to $value;
                    }
                    else
                    {
                        return 
    false;
                    }
                    break;
                case 
    'subject':
                    if( !empty(
    $value) )
                    {
                        
    $value stripslashes($value);
                        
    $value htmlspecialchars($value);
                        
                        
    $this->subject $value;
                    }
                    else
                    {
                        return 
    false;
                    }
                    break;
                case 
    'bcc':
                    if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$value) )
                    {
                        
    $this->bcc $value;
                    }
                    break;
                case 
    'cc':
                    if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$value) )
                    {
                        
    $this->cc $value;
                    }
                    break;
                case 
    'message':
                    
    $message stripslashes($value);
                    if( 
    $this->html !== true )
                    {
                        
    $message strip_tags($message);
                    }
                    
                    
    $this->message $message;
                    
                    break;    
                case 
    'mto':
                    if ( 
    is_array($value) )
                    {
                        
    $this->multiple_to($value);
                    }
                    else
                    {
                        if ( !isset(
    $this->to) )
                        {
                            
    $this->to $value;
                        }
                        else
                        {
                            
    $this->to .= ", " $value;
                        }
                    }
                    break;
                case 
    'mcc':
                    if ( 
    is_array($value) )
                    {
                        
    $this->multiple_cc($value);
                    }
                    else
                    {
                        if ( !isset(
    $this->cc) )
                        {
                            
    $this->cc $value;
                        }
                        else
                        {
                            
    $this->cc .= ", " $value;
                        }
                    }
                    break;
                case 
    'mbcc':
                    if ( 
    is_array($value) )
                    {
                        
    $this->multiple_bcc($value);
                    }
                    else
                    {
                        if ( !isset(
    $this->bcc) )
                        {
                            
    $this->bcc $value;
                        }
                        else
                        {
                            
    $this->bcc .= ", " $value;
                        }
                    }
                    break;
                case 
    'header':
                    
    $this->set_header($value);
                    break;
                case 
    'mailbb':
                    if( 
    $value == or $value === true )
                    {
                        
    $this->mailbb true;
                    }
                    break;
                default:
                    return 
    false;
            }
        }
        
        function 
    multiple_to$to )
        {
            if( !
    is_array($to) )
            {
                return 
    false;
            }
            else
            {
                if( 
    $this->send !== true )
                {
                    foreach ( 
    $to as $mail )
                    {
                        if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$mail) )
                        {
                            if ( empty(
    $this->to) )
                            {
                                
    $this->to $mail;
                            }
                            else
                            {
                                
    $this->to .= ", " $mail;
                            }

                        }
                    }
                }
            }    
        }
        
        function 
    multiple_cc$cc )
        {
            if( !
    is_array($cc) )
            {
                return 
    false;
            }
            else
            {
                if( 
    $this->send !== true )
                {
                    foreach ( 
    $cc as $mail )
                    {
                        if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$mail) )
                        {
                            if ( empty(
    $this->cc) )
                            {
                                
    $this->cc $mail;
                            }
                            else
                            {
                                
    $this->cc .= ", " $mail;
                            }
                        }
                    }
                }
            }    
        }
        
        function 
    multiple_bcc$bcc )
        {
            if( !
    is_array($bcc) )
            {
                return 
    false;
            }
            else
            {
                if( 
    $this->send !== true )
                {
                    foreach ( 
    $bcc as $mail )
                    {
                        if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$mail) )
                        {
                            if ( empty(
    $this->bcc) )
                            {
                                
    $this->bcc $mail;
                            }
                            else
                            {
                                
    $this->bcc .= ", " $mail;
                            }
                        }
                    }
                }
            }    
        }
        
        function 
    set_header$header )
        {
            
    $headers $this->headers;
            
            
    $headers preg_replace("#\r\n\r\n$#""\r\n"$headers);
            
            
    $headers .= $header "\r\n";
            
            
    $this->headers $headers;
        }
        
        function 
    mailbb$message )
        {
            
    $search = array(
                
    '\[b\](.*?)\[/b\]' => '<strong>\1</strong>',
                
    '\[i\](.*?)\[/i\]' => '<i>\1</i>',
                
    '\[u\](.*?)\[/u\]' => '<u>\1</u>',        
                
    '\[center\](.*?)\[/center\]' => '<div style="width:100%; text-align:center;">\1</div>',
                
    '\[url=(.*?)\](.*?)\[/url\]' => '<a href="\1">\2</a>',
                
    '\[url\](.*?)\[/url\]' => '<a href="\1">\1</a>',
                
    '\[color=(.*?)\](.*?)\[/color\]' => '<span style="color:\1;">\2</span>',
                
    '\[img=(.*?)\](.*?)\[/img\]' => '<img src="\1" alt="\2" border="0" />',
                
    '\[img\](.*?)\[/img\]' => '<img src="\1" alt="Image" border="0" />'
            
    );
        
            foreach(
    $search as $s => $r)
            {
                
    $message preg_replace("#" $s "#is"$r$message);
            }
            
            
    $message '<html>
            <head>
            <title>'
    $this->subject .'</title>
            </head>
            <body>' 
    str_replace("\n""\n<br />\n"$message) .'</body>
            </html>'
    ;
            
            return 
    $message;
        }
        
        function 
    send()
        {
            if( 
    is_array($this->to) )
            {
                foreach(
    $this->to as $mail)
                {
                    
    $to .= $mail .", ";
                }
                
    $this->to $to;
            }
            
            
    $this->set("header""From: " $this->from);
            
    $this->set("header""To: " $this->to);
            
            if ( !empty(
    $this->cc) && isset($this->cc) )
            {
                
    $this->set("header""CC: " $this->cc);
            }
            
            if ( !empty(
    $this->bcc) && isset($this->bcc) )
            {
                
    $this->set("header""BCC: " $this->bcc);
            }
            
            
    $this->set("header""X-Powered-By: fanrpg, SynN");
            
    $this->set("header""X-Mailer: PHP/"phpversion());
            
    $this->set("header""Return-Path: "$this->from);
            
            if( 
    $this->mailbb === true && $this->html !== true )
            {
                
    $this->message strip_tags($this->message);
                
    $this->set("header""Content-Type: text/html");
                
    $this->set("header""Content-Transfer-Encoding: 8bit");                    
            }
            
            if( 
    $this->mailbb === true )
            {
                
    $this->message $this->mailbb($this->message);
            }
            
            if( !
    mail($this->to$this->subject$this->message$this->headers "\r\n") )
            {
                return 
    false;
            }
            else
            {
                
    $this->send true;
            }
        }
        
        function 
    clean()
        {
            
    $this->to "";
            
    $this->from "";
            
    $this->subject "";
            
    $this->headers "";
            
    $this->message "";
            
    $this->bcc "";
            
    $this->cc "";
            
    $this->send false;
            
    $this->html false;
        }
    }
    ?>
     
    #1 Spacerat, Jul 24, 2007
  2. alex
    alex killed in action
    Joined:
    Dec 30, 2006
    Messages:
    8,187
    Likes Received:
    282
    1. SysProfile:
    63644
    2. SysProfile:
    18897
    40873

    also soweit ich das versteh, ist das ein PHP-Mailer, oder? :o
    also nur die funktion
     
  3. Spacerat
    Spacerat ٩(̾●̮̮̃̾•̃̾)۶ /dev/null
    Threadstarter
    Joined:
    Dec 25, 2006
    Messages:
    8,597
    Likes Received:
    196
    Name:
    Christian
    1. SysProfile:
    11226
    Steam-ID:
    Spacerat2911
    jap, die mailerclass. Die kannste includen, dann halt mails damit verschicken. Erlaubt auch HTML-Mails ;)
     
    #3 Spacerat, Jul 24, 2007
  4. alex
    alex killed in action
    Joined:
    Dec 30, 2006
    Messages:
    8,187
    Likes Received:
    282
    1. SysProfile:
    63644
    2. SysProfile:
    18897
    40873
    okay ich hab mir das mal kopiert, vllt brauch ich's irgendwann mal :D
     
  5. Spacerat
    Spacerat ٩(̾●̮̮̃̾•̃̾)۶ /dev/null
    Threadstarter
    Joined:
    Dec 25, 2006
    Messages:
    8,597
    Likes Received:
    196
    Name:
    Christian
    1. SysProfile:
    11226
    Steam-ID:
    Spacerat2911
    Als kleines Update wurde nun ein einfaches Template-System hinzugefügt. Alles wichtige steht im Beispiel beschrieben. Vielleicht finden sich ja auch ein paar Fans mehr als nur alexirsi ;)

    PHP:
    <?php
    #################################################
    ##
    ##
    ##        BBCode Supporting E-Mail Class
    ##        with massmail function
    ##
    ##        Author: SynN/Spacerat and fanrpg (c) 2007
    ##        Date: 07/23/07
    ##
    ##        Version: 1.1.0
    ##        
    ##        Licensed under GNU Public License
    ##        http://opensource.org/licenses/gpl-license.php
    ##
    ##
    #################################################

    #################################################
    ##
    ##         History:
    ##
    ##        v1.0.0 
    ##            - First Public Release
    ##
    ##        v1.1.0
    ##            - Added template system for emails from private version
    ##
    #################################################

    #################################################
    ##
    ##        Example:
    ##        
    ##        $mail = new Email();
    ##
    ##        $mail->set("from", "absender@example.com");
    ##        $mail->set("to", "empfaenger@example.com"); // You can use mto to send massmail ( $mail->set("mto", array("mail@example.com", "mail2@example.com")) )
    ##        $mail->set("subject", "Betreff"); // Subject for mail
    ##        $mail->set("html", 1) // html email 1 = on, 0 = off
    ##        $mail->set("mailbb", 1) // bbcode for mails 1 = on, 0 = off
    ##        $mail->set("message", "Message of the Mail");
    ##        $mail->send();
    ##        $mail->clean();
    ##
    ##        Optional commands:
    ##
    ##        $mail->set("header", "own header"); // to set own header..
    ##        $mail->set("bcc", "bcc@example.com"); // to send a blindcopy
    ##        $mail->set("cc", "cc@example.com"); // to send a copy
    ##        $mail->set("template", "./path/filename.html"); // to set a template file
    ##        $mail->set("template_vars", array(
    ##            'NAME' => 'Value',
    ##            'NAME_VAR' => $value
    ##        )); // To set template vars.. no loops, manually message was then before template message, html is auto enabled
    ##
    ##        You can use mbcc, mcc to send mass bcc or cc, like to use mto.
    ##        You can also combine to and mto, cc and mcc, bcc and mbcc and all of them with arrays or just strings.
    ##
    #################################################

    class Email
    {
        var 
    $from;
        var 
    $to;
        var 
    $subject;
        var 
    $headers;
        var 
    $bcc;
        var 
    $cc;
        var 
    $message;
        var 
    $mailbb;
        var 
    $mail_tpl;
        var 
    $html false;
        var 
    $send false;
        
        
        function 
    set($type$value)
        {
            switch( 
    $type )
            {
                case 
    'html':
                    if( 
    $value == or $value === true )
                    {
                        
    $this->html true;
                        
    $this->set("header""Content-Type: text/html");
                        
    $this->set("header""Content-Transfer-Encoding: 8bit");
                    }
                    break;
                case 
    'from':
                    if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$value) )
                    {
                        
    $this->from $value;
                    }
                    else
                    {
                        return 
    false;
                    }
                    break;
                case 
    'to':
                    if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$value) )
                    {
                        
    $this->to $value;
                    }
                    else
                    {
                        return 
    false;
                    }
                    break;
                case 
    'subject':
                    if( !empty(
    $value) )
                    {
                        
    $value stripslashes($value);
                        
    $value htmlspecialchars($value);
                        
                        
    $this->subject $value;
                    }
                    else
                    {
                        return 
    false;
                    }
                    break;
                case 
    'bcc':
                    if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$value) )
                    {
                        
    $this->bcc $value;
                    }
                    break;
                case 
    'cc':
                    if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$value) )
                    {
                        
    $this->cc $value;
                    }
                    break;
                case 
    'message':
                    
    $message stripslashes($value);
                    if( 
    $this->html !== true )
                    {
                        
    $message strip_tags($message);
                    }
                    
                    
    $this->message $message;
                    
                    break;    
                case 
    'mto':
                    if ( 
    is_array($value) )
                    {
                        
    $this->multiple_to($value);
                    }
                    else
                    {
                        if ( !isset(
    $this->to) )
                        {
                            
    $this->to $value;
                        }
                        else
                        {
                            
    $this->to .= ", " $value;
                        }
                    }
                    break;
                case 
    'mcc':
                    if ( 
    is_array($value) )
                    {
                        
    $this->multiple_cc($value);
                    }
                    else
                    {
                        if ( !isset(
    $this->cc) )
                        {
                            
    $this->cc $value;
                        }
                        else
                        {
                            
    $this->cc .= ", " $value;
                        }
                    }
                    break;
                case 
    'mbcc':
                    if ( 
    is_array($value) )
                    {
                        
    $this->multiple_bcc($value);
                    }
                    else
                    {
                        if ( !isset(
    $this->bcc) )
                        {
                            
    $this->bcc $value;
                        }
                        else
                        {
                            
    $this->bcc .= ", " $value;
                        }
                    }
                    break;
                case 
    'header':
                    
    $this->set_header($value);
                    break;
                case 
    'mailbb':
                    if( 
    $value == or $value === true )
                    {
                        
    $this->mailbb true;
                    }
                    break;
                case 
    'template':
                    if( 
    file_exists($value) )
                    {
                        if( !(
    $tpl file_get_contents($value)) )
                        {
                            if( 
    $handle fopen($value"r") )
                            {
                                
    $tpl fread($handlefilesize($value));
                                
    fclose($handle);
                            }
                            else
                            {
                                return 
    false;
                            }
                        }
                    }
                    else
                    {
                        return 
    false;
                    }
                    
    $this->mail_tpl $tpl;
                    break;
                case 
    'template_vars':
                    if( !
    is_array($value) )
                    {
                        return 
    false;
                    }
                    else
                    {
                        foreach( 
    $value as $name => $var )
                        {
                            
    $this->mail_tpl str_replace("{var "$name ."}"$var$this->mail_tpl);
                        }
                        
                        
    $this->message = ( empty($this->message) ) ? $this->mail_tpl $this->message $this->mail_tpl;
                        
    $this->set("html"1);
                    }
                    break;
                default:
                    return 
    false;
            }
        }
        
        function 
    multiple_to$to )
        {
            if( !
    is_array($to) )
            {
                return 
    false;
            }
            else
            {
                if( 
    $this->send !== true )
                {
                    foreach ( 
    $to as $mail )
                    {
                        if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$mail) )
                        {
                            if ( empty(
    $this->to) )
                            {
                                
    $this->to $mail;
                            }
                            else
                            {
                                
    $this->to .= ", " $mail;
                            }

                        }
                    }
                }
            }    
        }
        
        function 
    multiple_cc$cc )
        {
            if( !
    is_array($cc) )
            {
                return 
    false;
            }
            else
            {
                if( 
    $this->send !== true )
                {
                    foreach ( 
    $cc as $mail )
                    {
                        if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$mail) )
                        {
                            if ( empty(
    $this->cc) )
                            {
                                
    $this->cc $mail;
                            }
                            else
                            {
                                
    $this->cc .= ", " $mail;
                            }
                        }
                    }
                }
            }    
        }
        
        function 
    multiple_bcc$bcc )
        {
            if( !
    is_array($bcc) )
            {
                return 
    false;
            }
            else
            {
                if( 
    $this->send !== true )
                {
                    foreach ( 
    $bcc as $mail )
                    {
                        if( 
    preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4}|museum)/i"$mail) )
                        {
                            if ( empty(
    $this->bcc) )
                            {
                                
    $this->bcc $mail;
                            }
                            else
                            {
                                
    $this->bcc .= ", " $mail;
                            }
                        }
                    }
                }
            }    
        }
        
        function 
    set_header$header )
        {
            
    $headers $this->headers;
            
            
    $headers preg_replace("#\r\n\r\n$#""\r\n"$headers);
            
            
    $headers .= $header "\r\n";
            
            
    $this->headers $headers;
        }
        
        function 
    mailbb$message )
        {
            
    $search = array(
                
    '\[b\](.*?)\[/b\]' => '<strong>\1</strong>',
                
    '\[i\](.*?)\[/i\]' => '<i>\1</i>',
                
    '\[u\](.*?)\[/u\]' => '<u>\1</u>',        
                
    '\[center\](.*?)\[/center\]' => '<div style="width:100%; text-align:center;">\1</div>',
                
    '\[url=(.*?)\](.*?)\[/url\]' => '<a href="\1">\2</a>',
                
    '\[url\](.*?)\[/url\]' => '<a href="\1">\1</a>',
                
    '\[color=(.*?)\](.*?)\[/color\]' => '<span style="color:\1;">\2</span>',
                
    '\[img=(.*?)\](.*?)\[/img\]' => '<img src="\1" alt="\2" border="0" />',
                
    '\[img\](.*?)\[/img\]' => '<img src="\1" alt="Image" border="0" />'
            
    );
        
            foreach(
    $search as $s => $r)
            {
                
    $message preg_replace("#" $s "#is"$r$message);
            }
            
            
    $message '<html>
            <head>
            <title>'
    $this->subject .'</title>
            </head>
            <body>' 
    str_replace("\n""\n<br />\n"$message) .'</body>
            </html>'
    ;
            
            return 
    $message;
        }
        
        function 
    send()
        {
            if( 
    is_array($this->to) )
            {
                foreach(
    $this->to as $mail)
                {
                    
    $to .= $mail .", ";
                }
                
    $this->to $to;
            }
            
            
    $this->set("header""From: " $this->from);
            
    $this->set("header""To: " $this->to);
            
            if ( !empty(
    $this->cc) && isset($this->cc) )
            {
                
    $this->set("header""CC: " $this->cc);
            }
            
            if ( !empty(
    $this->bcc) && isset($this->bcc) )
            {
                
    $this->set("header""BCC: " $this->bcc);
            }
            
            
    $this->set("header""X-Powered-By: fanrpg, SynN");
            
    $this->set("header""X-Mailer: PHP/"phpversion());
            
    $this->set("header""Return-Path: "$this->from);
            
            if( 
    $this->mailbb === true && $this->html !== true )
            {
                
    $this->message strip_tags($this->message);
                
    $this->set("header""Content-Type: text/html");
                
    $this->set("header""Content-Transfer-Encoding: 8bit");                    
            }
            
            if( 
    $this->mailbb === true )
            {
                
    $this->message $this->mailbb($this->message);
            }
            
            if( !
    mail($this->to$this->subject$this->message$this->headers "\r\n") )
            {
                return 
    false;
            }
            else
            {
                
    $this->send true;
            }
        }
        
        function 
    clean()
        {
            
    $this->to "";
            
    $this->from "";
            
    $this->subject "";
            
    $this->headers "";
            
    $this->message "";
            
    $this->bcc "";
            
    $this->cc "";
            
    $this->mail_tpl "";
            
    $this->send false;
            
    $this->html false;
        }
    }
    ?>
     
    #5 Spacerat, Jul 26, 2007
  6. fas
    fas Hardware-Wissenschaftler
    Joined:
    Jul 24, 2007
    Messages:
    497
    Likes Received:
    4
    1. SysProfile:
    32074
    2. SysProfile:
    36546
    Hallo, hab mir mal dein script angeschaut. Ist nicht schlecht, hätte da aber ein paar Anregungen. Bitte nicht als Kritik verstehen ;-)


    1.: Für den Massenmailversand wäre es für den Verwender der Klasse einfacher, wenn man einfach als "to" ein Array angeben könnte,
    da ganz simpel per is_array() geprüft werden könnte, ob es sich um einen oder mehrere Empfänger handelt und das ganze dann entsprechend in der Klasse verwurschtet werden könnte.

    2.: CC ist quasi unnötig, da ja auch an mehrere Adressen gesendet werden kann - kann man aber auch lassen, falls doch mal ein CC gebraucht wird.
    Außerdem ist für den, der die Klasse nur verwenden möchte und nicht ins Innenleben schauen will unklar,
    ob, wenn er eine Massenmail schickt, bei jeder Mail eine CC/BCC gesendet wird, wenn CC/BCC angegeben.

    3.: Wieder für den, der die Klasse nur verwenden will, ist unklar, von welchem Pfad aus das Template
    included werden soll. Vom Server-Root aus? Vom aktuellen Verzeichnis? Dazu muss er in die Klasse reinschauen.

    4.: Wenn die Nachricht leer ist, wird nur das Template gesendet - welchen Sinn hat das?

    5.: Das Template wird nur an den Text angefügt. Was ist, wenn man den Text innerhalb des Templates haben will? Hier wäre eine Möglichkeit, sowas wie ##text## im Template einzubauen, an deren Stelle der Text eingefügt wird, sinniger.

    6.: Es wird nirgens beschrieben, wie die Variabeln einzusetzen sind ({var XY}).

    7.: Wieder für den, der es nur verwenden will, ist überhaupt mal unklar, was die Variabeln für einen Sinn haben,
    bzw. wo sie durch was ersetzt werden (sollen).

    8.: Die Emailprüfung ist sehr schlecht. Das sieht mir nach was geklautem aus. Außerdem lehnt es so manche gültige Emailadresse ab, wie z.B. hänschen@hänschenhausen.travel - Umlaute werden nicht akzeptiert und abgesehen von "museum" wird auch keine Domainendung mit mehr als 4 Zeichen akzeptiert. Desweiteren werden Großbuchstaben und Sonderzeichen nicht akzeptiert - wobei dies beides vor dem @ durchaus vorkommen kann.

    9.: Die Prüfung der Emailadressen hätte man leichter in z.B. eine Funktion ausgelagert, da so bei einer evtl.
    Änderung des Prüfstrings nur einmal alles geändert werden müsste.
    Da es aber für die FROM/TO/CC/BCC jedesmal extra kopiert wurde, muss man es im Falle einer Änderung überall
    umschreiben. Das bedeutet nicht nur einen zeitlichen Mehraufwand, sondern auch eine weitere Fehlerquelle.

    10.: Die Funktionen multiple_to/multiple_cc/multiple_bcc sind bis auf die Änderung TO/CC/BCC identisch.
    Einfacher wäre hier, eine Funktion multiple_X($person_to_send,$person_type), und dann einfach jeweils TO/CC/BCC
    dynamisch innerhalb der Funktion zu bestimmen, bzw. einfach die Rückgabe als TO/CC/BCC zu setzen. Spart wieder Tipparbeit & Speicher und eine Fehlerquelle mehr wird beseitigt. Außerdem ist hier wieder die gecopy&gepastete Version der Emailprüfung drin...


    Im Großen und Ganzen ist die Klasse zwar recht übersichtlich gehalten, es fehlen jedoch jedliche Kommentare innerhalb der Klasse.

    Wünsche noch viel Spass beim coden.

    MFG
     
  7. Spacerat
    Spacerat ٩(̾●̮̮̃̾•̃̾)۶ /dev/null
    Threadstarter
    Joined:
    Dec 25, 2006
    Messages:
    8,597
    Likes Received:
    196
    Name:
    Christian
    1. SysProfile:
    11226
    Steam-ID:
    Spacerat2911
    Dafür gibt es doch mto, mit Array-use ;)
    Wir haben diese Funktionen extra auch klar noch einmal getrennt, um den "User" nicht zu verunsichern.

    CC hat ja seinen Grund, nicht nur bei dem Script. CC bedeutet Carbon Copy, so viel wie "Durchschlag", z.B. wenn jemand das nur "nebenbei" bekommen soll. Ich z.B. filtere zu Haus auch meine Mails nach An und CC.. Wenn ich nur einen "Durchschlag" bekomme und kein Hauptempfänger sind, weiß ich z.B., dass ich mich nicht sofort um diese Mail kümmern muss ;)

    Das kann man aus jedem Pfad nehmen. Der Pfad wird nicht explizit vorher deklariert sondern direkt vom "User" angegeben, relativ zum Aufruf-Pfad des Hauptscripts, dass die Class included.

    Dafür sind doch Variablen da, jeder Benutzer des Scripts hat doch die Chance, entweder das Template zu nutzen ODER einen Text zu senden. Wenn an ein Template noch was angehängt werden soll, kann zum Template doch noch Text versendet werden. Wenn das Template leer ist, kann ich/können wir dagegen ja nix machen ;)

    Wie gesagt, Templatevariablen ;)

    Ok, das reichen wir nach ;D

    Die ist eigentlich standard. Gut, es gibt noch .mobile als Erweiterung... Die könnt ich nachreichen. Die Umlaute sind eh noch nicht verbreitet, aber die hinzuzufügen wäre denk ich auch nicht schlecht.

    Wait for V 1.20 ;)

    Wir haben das bisher noch auseinandergehalten, bis es etwas unübersichtlicher wird. Wir finden beide, dass es anfangs so komfortabler ist.


    Kommentare kommen auch noch, obwohl eigentlich das Beispiel oben reichen sollt. Die Kommis machen es DANN wieder unübersichtlich, aber mal sehn ;)

    Spacey
     
    #7 Spacerat, Jul 26, 2007
  8. fas
    fas Hardware-Wissenschaftler
    Joined:
    Jul 24, 2007
    Messages:
    497
    Likes Received:
    4
    1. SysProfile:
    32074
    2. SysProfile:
    36546
    Zitat:
    Dafür gibt es doch mto, mit Array-use
    Wir haben diese Funktionen extra auch klar noch einmal getrennt, um den "User" nicht zu verunsichern.

    Ich weiss nicht, was es da zu verunsichern gibt.
    Wenn der User nur eine Mail schicken will, dann gibt er eine Adresse ein.
    Wenn er mehrere schicken will, überigbt er ein Array.
    Und ein simpler Kommentar à la "1 Emailadresse oder mehrere Adressen im Array" würde alles klar stellen.
    Ich mein, musst du selber wissen, ist dein Script, aber ich finde es überflüssig.


    Zitat:
    CC hat ja seinen Grund, nicht nur bei dem Script. CC bedeutet Carbon Copy, so viel wie "Durchschlag", z.B. wenn jemand das nur "nebenbei" bekommen soll. Ich z.B. filtere zu Haus auch meine Mails nach An und CC.. Wenn ich nur einen "Durchschlag" bekomme und kein Hauptempfänger sind, weiß ich z.B., dass ich mich nicht sofort um diese Mail kümmern muss.

    So ein Käse.
    Ich weiss, was CC bedeutet.
    Trotzdem bleibt unklar, ob, wenn ich als CC "hanz@hanz.hanz" angebe und die Mail an 5000 Leute schicke, ob bei jedem der 5000 Mails nochmal der CC "hanz@hanz.hanz" drinsteht.
    Wie du deine Mails sortierst ist natürlich deine Sachen, drum habe ich ja gesagt, dass es ok ist. Nur bleibt eben dem, der sich nicht ins Innenleben der Klasse verirren, sondern Sie nur anwenden möchte, wie erwähnt, unklar, ob der CC dann in diesem Beispiel 5000 mal die Mail erhält.


    Zitat:
    Das kann man aus jedem Pfad nehmen. Der Pfad wird nicht explizit vorher deklariert sondern direkt vom "User" angegeben, relativ zum Aufruf-Pfad des Hauptscripts, dass die Class included.

    Das habe ich auch gesehen.
    Weiss der User aber doch nicht.


    Zitat:Zitat von fas
    6.: Es wird nirgens beschrieben, wie die Variabeln einzusetzen sind ({var XY}).
    Zitat:
    Ok, das reichen wir nach ;D


    Wenn du/ihr das nachgereicht habt, können wir ja über Punkt 4, 5 und 7 nochmal sprechen.
    Weil so macht das mit dem Template und den Variabeln keinen Sinn.
    Als User frage ich mich: Was sind die Variabeln? Was ist das Template? Wer bindet was ein? Muss ich als der, der die Klasse in ein System/eine Website einbindet, Variabeln vergeben? oder macht das der User.
    Und nochmal zum versenden des leeren Templates: Wenn einer keinen Text eingibt und versehentlich auf OK klickt, wird eben nur das leere Template versendet. Eine Fehlermeldung von wegen "kein Text eingegeben" wäre sinniger.

    zur Emailprüfung:
    Zitat:
    Die ist eigentlich standard. Gut, es gibt noch .mobile als Erweiterung... Die könnt ich nachreichen. Die Umlaute sind eh noch nicht verbreitet, aber die hinzuzufügen wäre denk ich auch nicht schlecht.


    Was heisst hier Standard?
    Wo ist das Standard?
    *.mobile gibt es nicht. Du meinst sicher *.mobi, was in dem Fall funktionieren würde.
    Aber es gibt z.B. noch wie bereits erwähnt *.travel
    Und wer weiss, was für Endungen noch kommen werden?
    Berlin wollte mal *.berlin haben usw.
    Umlaute sind zwar noch nicht so verbreitet wie normale Adressen, aber das interessiert den User, der seine Umlautemailadresse eingibt und eine Fehlermeldung bekommt, reichlich wenig.
    Es ist kaum Aufwand, Umlaute und Sonderzeichen zur Prüfung hinzuzufügen.
    Und wenn du eine Funktion zum prüfen der Emailadresse hättest und das nicht nur überall hingecopy&gepastet hättest, ginge das noch viel schneller.
    Aber wenn du das eh änderst, kannst du auch gleich so eine Funktion machen. ;-)


    Zitat:Zitat von fas
    9.: Die Prüfung der Emailadressen hätte man leichter in z.B. eine Funktion ausgelagert, da so bei einer evtl.
    Änderung des Prüfstrings nur einmal alles geändert werden müsste.

    Da es aber für die FROM/TO/CC/BCC jedesmal extra kopiert wurde, muss man es im Falle einer Änderung überall
    umschreiben. Das bedeutet nicht nur einen zeitlichen Mehraufwand, sondern auch eine weitere Fehlerquelle.


    Zitat:Zitat von fas
    10.: Die Funktionen multiple_to/multiple_cc/multiple_bcc sind bis auf die Änderung TO/CC/BCC identisch.

    Einfacher wäre hier, eine Funktion multiple_X($person_to_send,$person_type), und dann einfach jeweils TO/CC/BCC
    dynamisch innerhalb der Funktion zu bestimmen, bzw. einfach die Rückgabe als TO/CC/BCC zu setzen. Spart wieder Tipparbeit & Speicher und eine Fehlerquelle mehr wird beseitigt. Außerdem ist hier wieder die gecopy&gepastete Version der Emailprüfung drin...

    Zitat:
    Wir haben das bisher noch auseinandergehalten, bis es etwas unübersichtlicher wird. Wir finden beide, dass es anfangs so komfortabler ist.

    Es ist nicht komfortabler.
    Es ist nur aufwändiger.


    Zitat:
    Kommentare kommen auch noch, obwohl eigentlich das Beispiel oben reichen sollt. Die Kommis machen es DANN wieder unübersichtlich, aber mal sehn.


    Ich kenne ja eure Vorgeschichte nicht, und weiss nicht, was ihr sonst für Prjekte verwaltet, aber glaubt mir: Kommentare machen es definitiv übersichtlich und nicht unübersichtlich.
    Vor allem, wenn es mal größer wird.
    Ich habe große Projekte, ohne Kommentare wäre ich verloren.
    Zumal es selbst bei so einem Mini-Scriptchen geschätzte 10-20 Minuten dauert, bis man sich reinließt.
    Und gerade, wenn du das ganze als OpenSource vertreiben willst, solltest du Kommentare einbauen, da sich das Andere auch anschauen werden.
    Und wenn du da jetzt 1 Jahr lang nichts mehr dran machst und dann mal wieder reinschaust, wirst du froh sein, Kommentare drin zu haben.

    Und nochmal: "Kommentare kommen noch"..... <-- Dann macht das ganze doch bitte als Version 0.0Xa und nicht als 1.1 oder was das ist.
    Wenn ihr das Ganze sonst nicht nicht veröffentlicht habt, killt diese Versionsnummer und nennt das jetzt 0.01a oder 0.02a, wenn das schon die zweite Version ist.
    Und wenn es dann fertig ist, macht ihr Version 0.3a draus.
    Und erst, wenn keine Fehler mehr auftauchen, macht ihr eine beta draus.
    Und wenn das dann eine Weile läuft macht ihr eine 0.3 rc1 draus und anschließend wird daraus dann die 0.3 final.

    Denn so wird sich keiner darüber aufregen, dass er eine Version > 1 hat, die nicht richtig funktioniert.
     
  9. fanrpg
    fanrpg Computer-Guru
    Joined:
    Jul 27, 2007
    Messages:
    161
    Likes Received:
    16
    1. SysProfile:
    30134
    So ist das nicht richtig.
    Es gab eine längere Beta-Phase, das enstandene Produkt war Version 1.0.0, nebenbei noch die private Versiob die nicht öffentlich zugänglich gemacht wird.. das ist mehr die Entwicklerversion (+ aller Bugs). Beta-Phasen werden mit einem geschlossenem Beta-Tester Kreis durchgeführt u.a auch in Live-Umgebungen.. wo Fehler eg. auffallen sollten. Erst wenn ein Teil soweit funktioniert das es funktionsfähig und bugfrei erscheint wird es in die öffentliche Version übernommen. Die End-Version wird dann nur noch angepasst.. da die Private-Version ein paar kleinere Features ausweist als die öffentliche und daher auch mehr Variablen.. daher auch bei der v1.2.0 musste ein Teil speziell dafür geschrieben werden. Weil es codetechnisch nicht gepasst hätte und das anpassen länger gedauert hätte als das neuschreiben. Daher auch eine Beta-Phase bei v.1.2.0 die mit Erfolg abgeschlossen werden konnte. Wie ich hier gerade bemerke wurd hier v.1.1.1 nicht veröffentlich in der ein paar der genannten Kritikpunkte verbessert wurden.

    Hier die v1.2.0
    PHP:
    <?php
    #################################################
    ##
    ##
    ##        BBCode Supporting E-Mail Class
    ##        with massmail function
    ##
    ##        Author: SynN and fanrpg (c) 2007
    ##        Date: 07/23/07
    ##
    ##        Version: 1.2.0
    ##        
    ##        Licensed under GNU Public License
    ##        http://opensource.org/licenses/gpl-license.php
    ##
    ##
    #################################################

    #################################################
    ##
    ##         History:
    ##
    ##        v1.0.0 
    ##            - First Public Release
    ##
    ##        v1.1.0
    ##            - Added template system for emails from private version
    ##        
    ##        v1.1.1
    ##            - Fixing Bug (#22)
    ##            - Fixing Bug (#23)
    ##            - Added validate_email()
    ##            - .mobile-tld allowed
    ##            - Added global message template var ( {MESSAGE} )
    ##
    ##        v1.2.0 Beta
    ##            - Fixing Bug (#24)
    ##            - Fixing Bug (#25)
    ##            - Fixing Bug (#26)
    ##            - Added archive function from private version
    ##            - Added archive to mail send function
    ##
    ##        v1.2.0 
    ##            - Fixing Bug (#27)
    ##            - Fixing Bug (#28)
    ##            - Fixing Bug (#29)
    ##            - Fixing Bug (#30)
    ##            - Fixing Bug (#31)
    ##            - Fixing Bug (#32)
    ##            - Fixing Bug (#33)
    ##            - Improve mailbb function
    ##            - Improve send_archive function
    ##             - Fixed archive to mail function (rewritten)
    ##
    #################################################

    #################################################
    ##
    ##        Example:
    ##        
    ##        $mail = new Email();
    ##
    ##        $mail->set("from", "absender@example.com");
    ##        $mail->set("to", "empfaenger@example.com"); // You can use mto to send massmail ( $mail->set("mto", array("mail@example.com", "mail2@example.com")) )
    ##        $mail->set("subject", "Betreff"); // Subject for mail
    ##        $mail->set("html", 1) // html email 1 = on, 0 = off
    ##        $mail->set("mailbb", 1) // bbcode for mails 1 = on, 0 = off
    ##        $mail->set("message", "Message of the Mail");
    ##        $mail->send();
    ##        $mail->clean();
    ##
    ##        Optional commands:
    ##
    ##        $mail->set("header", "own header"); // to set own header..
    ##        $mail->set("bcc", "bcc@example.com"); // to send a blindcopy
    ##        $mail->set("cc", "cc@example.com"); // to send a copy
    ##        $mail->set("template", "./path/filename.html"); // to set a template file
    ##        $mail->set("template_vars", array(
    ##            'NAME' => 'Value',
    ##            'NAME_VAR' => $value
    ##        )); // To set template vars.. no loops, manually message was then before template message, html is auto enabled
    ##
    ##        You can use mbcc, mcc to send mass bcc or cc, like to use mto.
    ##        You can also combine to and mto, cc and mcc, bcc and mbcc and all of them with arrays or just strings.
    ##
    #################################################

    error_reporting(E_ALL);

    class 
    Email
    {
        var 
    $from;
        var 
    $to;
        var 
    $subject;
        var 
    $headers;
        var 
    $bcc;
        var 
    $cc;
        var 
    $message;
        var 
    $mailbb;
        var 
    $mail_tpl;
        var 
    $html false;
        var 
    $send false;
        var 
    $archive false;
        
        
        function 
    set($type$value)
        {
            switch( 
    $type )
            {
                case 
    'html':
                    if( 
    $value == or $value === true )
                    {
                        
    $this->html true;
                    }
                    return 
    true;
                    break;
                case 
    'from':
                    if( 
    $this->validate_email$value ) )
                    {
                        
    $this->from $value;
                        return 
    true;
                    }
                    else
                    {
                        return 
    false;
                    }
                    break;
                case 
    'to':
                    if( 
    $this->validate_email$value ) )
                    {
                        
    $this->to $value;
                        return 
    true;
                    }
                    else
                    {
                        return 
    false;
                    }
                    break;
                case 
    'subject':
                    if( !empty(
    $value) )
                    {
                        
    $value stripslashes($value);
                        
    $value htmlspecialchars($value);
                        
                        
    $this->subject $value;
                        return 
    true;
                    }
                    else
                    {
                        return 
    false;
                    }
                    break;
                case 
    'bcc':
                    if( 
    $this->validate_email$mail ) )
                    {
                        
    $this->bcc $value;
                        return 
    true;
                    }
                    else
                    {
                        return 
    false;
                    }
                    break;
                case 
    'cc':
                    if( 
    $this->validate_email$mail ) )
                    {
                        
    $this->cc $value;
                        return 
    true;
                    }
                    else
                    {
                        return 
    false;
                    }
                    break;
                case 
    'message':
                    
    $message stripslashes($value);
                    if( 
    $this->html !== true )
                    {
                        
    $message strip_tags($message);
                    }
                    
                    
    $this->message $message;
                    return 
    true;
                    
                    break;    
                case 
    'mto':
                    if ( 
    is_array($value) )
                    {
                        return 
    $this->multiple_to($value);
                    }
                    else
                    {
                        if ( !isset(
    $this->to) )
                        {
                            
    $this->to $value;
                        }
                        else
                        {
                            
    $this->to .= ", " $value;
                        }
                        return 
    true;
                    }
                    break;
                case 
    'mcc':
                    if ( 
    is_array($value) )
                    {
                        return 
    $this->multiple_cc($value);
                    }
                    else
                    {
                        if ( !isset(
    $this->cc) )
                        {
                            
    $this->cc $value;
                        }
                        else
                        {
                            
    $this->cc .= ", " $value;
                        }
                        return 
    true;
                    }
                    break;
                case 
    'mbcc':
                    if ( 
    is_array($value) )
                    {
                        return 
    $this->multiple_bcc($value);
                    }
                    else
                    {
                        if ( !isset(
    $this->bcc) )
                        {
                            
    $this->bcc $value;
                        }
                        else
                        {
                            
    $this->bcc .= ", " $value;
                        }
                        return 
    true;
                    }
                    break;
                case 
    'header':
                    
    $this->set_header($value);
                    break;
                case 
    'mailbb':
                    if( 
    $value == or $value === true )
                    {
                        
    $this->mailbb true;
                        return 
    true;
                    }
                    break;
                case 
    'template':
                    if( 
    file_exists($value) )
                    {
                        if( !(
    $tpl file_get_contents($value)) )
                        {
                            if( 
    $handle fopen($value"r") )
                            {
                                
    $tpl fread($handlefilesize($value));
                                
    fclose($handle);
                            }
                            else
                            {
                                return 
    false;
                            }
                        }
                        return 
    true;
                    }
                    else
                    {
                        return 
    false;
                    }
                    
    $this->mail_tpl $tpl;
                    break;
                case 
    'template_vars':
                    if( !
    is_array($value) )
                    {
                        return 
    false;
                    }
                    else
                    {
                        foreach( 
    $value as $name => $var )
                        {
                            
    $this->mail_tpl str_replace("{var "$name ."}"$var$this->mail_tpl);
                        }
                        
                        
    $this->message = ( empty($this->message) ) ? $this->mail_tpl str_replace("{MESSAGE}"$this->message$this->mail_rpl);
                        return 
    $this->set("html"1);
                    }
                    break;
                case 
    'archive':
                    if( 
    $value == true or $value == )
                    {
                        
    $this->archive true;
                        return 
    true;
                    }
                    break;
                case 
    'send_archive':
                    if( !empty(
    $value) )
                    {
                        return 
    $this->send_archive$value );
                    }
                    else
                    {
                        return 
    false;
                    }
                    break;
                default:
                    return 
    false;
            }
        }
        
        function 
    multiple_to$to )
        {
            if( !
    is_array($to) )
            {
                return 
    false;
            }
            else
            {
                if( 
    $this->send !== true )
                {
                    foreach ( 
    $to as $mail )
                    {
                        if( 
    $this->validate_email$mail ) )
                        {
                            if ( empty(
    $this->to) )
                            {
                                
    $this->to $mail;
                            }
                            else
                            {
                                
    $this->to .= ", " $mail;
                            }

                        }
                    }
                    return 
    true;
                }
            }    
        }
        
        function 
    multiple_cc$cc )
        {
            if( !
    is_array($cc) )
            {
                return 
    false;
            }
            else
            {
                if( 
    $this->send !== true )
                {
                    foreach ( 
    $cc as $mail )
                    {
                        if( 
    $this->validate_email$mail ) )
                        {
                            if ( empty(
    $this->cc) )
                            {
                                
    $this->cc $mail;
                            }
                            else
                            {
                                
    $this->cc .= ", " $mail;
                            }
                        }
                    }
                    return 
    true;
                }
            }    
        }
        
        function 
    multiple_bcc$bcc )
        {
            if( !
    is_array($bcc) )
            {
                return 
    false;
            }
            else
            {
                if( 
    $this->send !== true )
                {
                    foreach ( 
    $bcc as $mail )
                    {
                        if( 
    $this->validate_email$mail ) )
                        {
                            if ( empty(
    $this->bcc) )
                            {
                                
    $this->bcc $mail;
                            }
                            else
                            {
                                
    $this->bcc .= ", " $mail;
                            }
                        }
                    }
                }
            }    
        }
        
        function 
    set_header$header )
        {
            
    $headers $this->headers;
            
            
    $headers preg_replace("#\r\n\r\n$#""\r\n"$headers);
            
            
    $headers .= $header "\r\n";
            
            
    $this->headers $headers;
            
            return 
    true;
        }
        
        function 
    mailbb$message )
        {        
            
    $search = array(            
                
    '#\[b\](.*?)\[/b\]#is',
                
    '#\[i\](.*?)\[/i\]#is',
                
    '#\[u\](.*?)\[/u\]#is',        
                
    '#\[center\](.*?)\[/center\]#is',
                
    '#\[url=(.*?)\](.*?)\[/url\]#is',
                
    '#\[url\](.*?)\[/url\]#is',
                
    '#\[color=(.*?)\](.*?)\[/color\]#is',
                
    '#\[img=(.*?)\](.*?)\[/img\]#is',
                
    '#\[img\](.*?)\[/img\]#i'
            
    );
            
            
    $replace = array(
                
    '<strong>\1</strong>',
                
    '<i>\1</i>',
                
    '<u>\1</u>',        
                
    '<div style="width:100%; text-align:center;">\1</div>',
                
    '<a href="\1">\2</a>',
                
    '<a href="\1">\1</a>',
                
    '<span style="color:\1;">\2</span>',
                
    '<img src="\1" alt="\2" border="0" />',
                
    '<img src="\1" alt="Image" border="0" />'
            
    );
            
            
    $message preg_replace($search$replace$message);
            
            
    $message '<html>
            <head>
            <title>'
    $this->subject .'</title>
            </head>
            <body>' 
    str_replace("\n""\n<br />\n"$message) .'</body>
            </html>'
    ;
            
            return 
    $message;
        }
        
        function 
    send()
        {
            if( 
    is_array($this->to) )
            {
                foreach(
    $this->to as $mail)
                {
                    
    $to .= $mail .", ";
                }
                
    $this->to $to;
            }
            
            
    $this->set("header""From: " $this->from);
            
    $this->set("header""To: " $this->to);
            
            if ( !empty(
    $this->cc) && isset($this->cc) )
            {
                
    $this->set("header""CC: " $this->cc);
            }
            
            if ( !empty(
    $this->bcc) && isset($this->bcc) )
            {
                
    $this->set("header""BCC: " $this->bcc);
            }
            
            
    $this->set("header""X-Powered-By: fanrpg, SynN");
            
    $this->set("header""X-Mailer: PHP/"phpversion());
            
    $this->set("header""Return-Path: "$this->from);
            
            if( 
    $this->mailbb === true && $this->html !== true )
            {
                
    $this->message strip_tags($this->message);                
            }
            
            if( 
    $this->mailbb === true )
            {
                
    $this->message $this->mailbb($this->message);
            }
            
            if( 
    $this->mailbb === true or $this->html == true )
            {
                
    $this->set("header""Content-Type: text/html");
                
    $this->set("header""Content-Transfer-Encoding: 8bit");    
            }
            
            if( !
    mail($this->to$this->subject$this->message$this->headers "\r\n") )
            {
                return 
    false;
            }
            else
            {
                if( 
    $this->archive == true )
                {
                    
    $file "To: "$this->to "\n";
                    
    $file .= "From: " $this->from "\n";
                    if( !empty(
    $this->cc) )
                    {
                        
    $file .= "CC: "$this->cc "\n";
                    }
                    if( !empty(
    $this->bcc) )
                    {
                        
    $file .= "BCC: "$this->bcc "\n";
                    }
                    if( 
    $this->mailbb === true )
                    {
                        
    $file .= "MailBB: true\n";
                    }
                    if( 
    $this->html === true )
                    {
                        
    $file .= "HTML: true\n";
                    }
                    
    $file .= "Subject: "$this->subject "\n";
                    
    $file .= "<< end mail header\n\n";
                    
    $file .= "Message:\n";
                    
    $file .= $this->message."\n";
                    
    $file .= "<< end message\n\n";
                    
                    if( 
    $handle fopen("archive/".date('d-m-Y'time()) . 'email_archive' date("His"time()). ".txt""w") )
                    {
                        if( !
    fwrite($handle$file) )
                        {
                            return 
    false;
                        }
                        
    fclose($handle);
                    }
                    else
                    {
                        return 
    false;
                    }
                }
                                
                
    $this->send true;
                return 
    true;
            }
        }
        
        function 
    send_archive$file )
        {
            if( 
    file_exists($file) )
            {
                
    $value file($file);
                
                foreach(
    $value as $line => $content)
                {
                    
    $mail_pattern "(([a-z0-9äöü_-]+(\.[a-z0-9äöü_-]+)*@([0-9a-zäöü][0-9a-zäöü-]*[0-9a-zäöü]\.)+([a-z]{2,4}|museum|mobile)))";
                    if( 
    preg_match("#^To: $mail_pattern#i"$content$to) )
                    {
                        
    $this->set("to"trim($to[1]));
                    }
                    
                    if( 
    preg_match("#^From: $mail_pattern#i"$content$from) )
                    {
                        
    $this->set("from"trim($from[1]));
                    }
                    
                    if( 
    stristr($content"Subject:") )
                    {
                        
    $this->set("subject"trim(str_replace("Subject:"""$content)));
                    }    
                    
                    if( 
    preg_match("#^CC: $mail_pattern#i"$content$cc) )
                    {
                        
    $this->set("cc"trim($cc[1]));
                    }    
                                
                    if( 
    preg_match("#^BCC: $mail_pattern#i"$content$bcc) )
                    {
                        
    $this->set("bcc"trim($bcc[1]));
                    }
                            
                    if( 
    preg_match("#^MailBB: true#i"$content) )
                    {
                        
    $this->set("mailbb"true);
                    }
                    
                    if( 
    preg_match("#^HTML: true#i"$content) )
                    {
                        
    $this->set("html"true);
                    }
                    
                    if( 
    stristr($content"<<< end mail header") )
                    {
                        break;
                    }
                }
                
                
    $value file_get_contents($file);
                
                if( 
    preg_match("#Message:(.*?)<< end message#is"$value$message) )
                {
                    if( 
    preg_match("#<body>(.*?)</body>#is"$message[1], $message_html) )
                    {
                        
    $this->set("message"trim($message_html[1]));
                    }
                    else
                    {
                        
    $this->set("message"trim($message[1]));
                    }
                }
                else
                {
                    return 
    false;
                }
                
                return 
    true;
            }
            else
            {
                return 
    false;
            }
        }                    
        
        function 
    validate_email$mail )
        {
            if( 
    preg_match("/[a-z0-9äöü_-]+(\.[a-z0-9äöü_-]+)*@([0-9a-zäöü][0-9a-zäöü-]*[0-9a-zäöü]\.)+([a-z]{2,4}|museum|mobile)/i"$mail) )
            {
                return 
    true;
            }
            else
            {
                return 
    false;
            }
        }
        
        function 
    clean()
        {
            
    $this->to "";
            
    $this->from "";
            
    $this->subject "";
            
    $this->headers "";
            
    $this->message "";
            
    $this->bcc "";
            
    $this->cc "";
            
    $this->mail_tpl "";
            
    $this->send false;
            
    $this->html false;
            
    $this->archive false;
            
            return 
    true;
        }
    }
    ?>
    Später wird noch ein DL-Paket folgen, in dem erklärt wird wie genau welche Funktionen wie genutzt werden können.
     
    #9 fanrpg, Aug 7, 2007
    Last edited: Aug 9, 2007
  10. Just_a_Script
    Just_a_Script reporting for duty
    Joined:
    Feb 12, 2007
    Messages:
    6,527
    Likes Received:
    279
    Name:
    Sascha
    1. SysProfile:
    25020
    2. SysProfile:
    70843
    Steam-ID:
    SysPKiller
    ma ne blöde frage von nem noob in der hinsicht ? was kann ich damit machen
    un wo kann ich den code verwenden un wie ? etc ... hab da echt kp von :D
     
    #10 Just_a_Script, Oct 8, 2007
  11. fas
    fas Hardware-Wissenschaftler
    Joined:
    Jul 24, 2007
    Messages:
    497
    Likes Received:
    4
    1. SysProfile:
    32074
    2. SysProfile:
    36546
    ist nen phpmailer. Kann z.B. in HTML included werden sofern der server php installiert hat. Ist im normalfall aber standard. Dann können z.B. browserbasiert mails versendet werden.
     
    #11 fas, Oct 8, 2007
    Last edited: Oct 8, 2007
  12. Just_a_Script
    Just_a_Script reporting for duty
    Joined:
    Feb 12, 2007
    Messages:
    6,527
    Likes Received:
    279
    Name:
    Sascha
    1. SysProfile:
    25020
    2. SysProfile:
    70843
    Steam-ID:
    SysPKiller

    aso danke für info ;-)
     
    #12 Just_a_Script, Oct 8, 2007
Thema:

[UPDATE 26.7.07] PHP Mailerclass mit Massenmailfunktion und MailBB-Code

Loading...

[UPDATE 26.7.07] PHP Mailerclass mit Massenmailfunktion und MailBB-Code - Similar Threads - UPDATE PHP Mailerclass

Forum Date

Vivaldi 7.6: Browser-Update bringt neue Anpassungsmöglichkeiten

Vivaldi 7.6: Browser-Update bringt neue Anpassungsmöglichkeiten: Vivaldi 7.6: Browser-Update bringt neue Anpassungsmöglichkeiten Während andere Anbieter auf KI-gesteuerte Browsing-Erlebnisse setzen, gibt Vivaldi die Kontrolle zurück an die Nutzer. Der Fokus...
User-Neuigkeiten Thursday at 7:55 PM

Kindle-Update 5.18.5 bringt Vorlesefunktion mit

Kindle-Update 5.18.5 bringt Vorlesefunktion mit: Kindle-Update 5.18.5 bringt Vorlesefunktion mit Die Version 5.18.5 kommt mit einigen Neuerungen daher, die den Lesekomfort verbessern sollen. Mit an Bord ist die internationale Freigabe des...
User-Neuigkeiten Wednesday at 9:43 AM

Google Pixel 10: Weiteres September-Update in der Verteilung

Google Pixel 10: Weiteres September-Update in der Verteilung: Google Pixel 10: Weiteres September-Update in der Verteilung Die Geräte der aktuellen Generation bekommen damit das zweite Update im September 2025. Die neue Version trägt die Buildnummer...
User-Neuigkeiten Tuesday at 10:55 PM

Die PlayStation 5 bekommt ein praktisches Controller-Update und eine Energiesparfunktion

Die PlayStation 5 bekommt ein praktisches Controller-Update und eine Energiesparfunktion: Die PlayStation 5 bekommt ein praktisches Controller-Update und eine Energiesparfunktion Die interessanteste Neuerung (für mich) betrifft den DualSense Wireless-Controller, der jetzt mit bis zu...
User-Neuigkeiten Tuesday at 8:38 PM

Sonos mit großem Update: Philips-Hue-Steuerung per Sprache und Ende für ältere...

Sonos mit großem Update: Philips-Hue-Steuerung per Sprache und Ende für ältere...: Sonos mit großem Update: Philips-Hue-Steuerung per Sprache und Ende für ältere Android-Versionen Die Versionsnummer springt auf 80.28.36 für Android-Geräte und 80.28.32 für iOS. Eine interessante...
User-Neuigkeiten Tuesday at 6:22 PM

Todoist: Update mit Liquid Glass ist da

Todoist: Update mit Liquid Glass ist da: Todoist: Update mit Liquid Glass ist da Mit dem Launch von iOS 26 und iPadOS 26 rollt man pünktlich eine neue Version der iOS-App mit dem neuen Design aus. Die Liquid-Glass-Oberfläche sieht nicht...
User-Neuigkeiten Tuesday at 10:33 AM

Raycast mit Update für macOS und iOS

Raycast mit Update für macOS und iOS: Raycast mit Update für macOS und iOS Im Fokus stehen Design-Anpassungen wie etwa Liquid-Glass-Elemente in AI-Chat und der Fokus-Funktion, die sich jetzt harmonisch ins neue macOS-Design einfügen....
User-Neuigkeiten Tuesday at 10:33 AM

AirPods Pro 2 und AirPods 4 erhalten Firmware-Update

AirPods Pro 2 und AirPods 4 erhalten Firmware-Update: AirPods Pro 2 und AirPods 4 erhalten Firmware-Update Damit diese funktionieren, benötigen die Kopfhörer aber auch ein Firmware-Update. Eben jenes ist ab sofort verfügbar. AirPods Pro 2 und...
User-Neuigkeiten Tuesday at 7:13 AM

Plex für Android, iOS, iPadOS und tvOS mit Update: Neue Player-Funktionen und jede Menge Fixes

Plex für Android, iOS, iPadOS und tvOS mit Update: Neue Player-Funktionen und jede Menge Fixes: Plex für Android, iOS, iPadOS und tvOS mit Update: Neue Player-Funktionen und jede Menge Fixes Auch tvOS bekommt Fixes. Version 2025.25.0 bringt einige kleinere Neuerungen mit sich, die das...
User-Neuigkeiten Monday at 11:33 PM

iOS 26 ist da: Das steckt im Update

iOS 26 ist da: Das steckt im Update: iOS 26 ist da: Das steckt im Update Der neue „Liquid Glass“-Look zieht sich durch das gesamte System. Elemente sind transparenter, runder, anpassbarer, der iOS-Look bleibt aber in Summe erhalten....
User-Neuigkeiten Monday at 10:23 PM

ARD Mediathek mit Update: Dolby Atmos und mehr Komfort beim Streaming

ARD Mediathek mit Update: Dolby Atmos und mehr Komfort beim Streaming: ARD Mediathek mit Update: Dolby Atmos und mehr Komfort beim Streaming Version 10.8.0 für die Apple-Plattformen bringt zahlreiche neue Funktionen, die das Streaming-Erlebnis verbessern sollen. Wer...
User-Neuigkeiten Monday at 7:03 PM

IINA 1.4.0: Update bringt Plugin-System und viele neue Funktionen

IINA 1.4.0: Update bringt Plugin-System und viele neue Funktionen: IINA 1.4.0: Update bringt Plugin-System und viele neue Funktionen Die Entwickler haben die finale Version 1.4.0 veröffentlicht, die einige Neuerungen mit sich bringt. Der auf mpv und FFmpeg...
User-Neuigkeiten Monday at 3:53 PM

Wibutler: Update-Politik wird angepasst

Wibutler: Update-Politik wird angepasst: Wibutler: Update-Politik wird angepasst Die erste Generation, die 2022 durch den Nachfolger abgelöst wurde, erhält künftig nur noch sicherheitsrelevante Updates der Version 2.xx.. . Wibutler:...
User-Neuigkeiten Sep 13, 2025
[UPDATE 26.7.07] PHP Mailerclass mit Massenmailfunktion und MailBB-Code solved
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice