Ankündigung

Einklappen
Keine Ankündigung bisher.

Anänge per phpmailer verschicken

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Anänge per phpmailer verschicken

    Aloa,

    ich nutze zum Versenden von Anhängen eine abgewandelte Version von phpmailer (phpmailer-fe). Das script leist ein Formular aus und sendet die Daten via Email an mich. Im Formular gibt es die Option, eine Datei anzuhängen. Es funktioniert auch alles besten (relativ).Die Date wird richtig hochgeladen, eine Fehlermeldung erhalte ich auch nicht.
    Wenn ich die Mail dann im clienten abrufe, wird auch alles korreckt angezeigt. Speziell der Anhang. Öffnen lässt er sich jedoch nicht. Ich habe s mit mehrern Dateitypen probiert, erhalte aber immer das selbe Ergebniss. Ich vermute, dass alle Dateiinfos richtig gesendet werden, nur eben die Datei nicht. Hier mal das php:

    PHP-Code:
    <?php
    /**
     * Set if you wish the email to be from this email address instead of the
     * email address of the sender
     * - can only be set in the script
     * @var string
     */
    $fixedFromEmail ''//'webmaster@thisdomain.com';
    $fixedFromName  ''//'Webmaster'

    /**
     * 'Swap' out hack attempts
     * - can only be set in the script
     * @var array
     */
    $email_bad_array "\r|\n|to:|cc:|bcc:";

    /* ****************************************************************
     * Optional Form Configuration that can be set in script or in form
     * ***************************************************************/

    /**
     * Email Address to send the form contents "To"
     * - can be set in the script or in the form as a form variable
     * - for security, use this instead of using the form
     * @var string
     */
    if (!$recipient) {
      
    $recipient 'meine mail addi;
    } else {
      $recipient = eregi_replace($email_bad_array,'',$recipient);
      $recipient = str_replace(" ", "", $recipient);
    }

    /**
     * Email Address to "Cc" the form contents
     * separate multiple email addresses by comma
     * - for security, use this instead of using the form
     * ie: johndoe@yourdomain.com,janedoe@yourdomain.com
     * - can be set in the script or in the form as a form variable
     * @var string
     */
    if (!$cc) {
      $cc = "";
    } else {
      $cc = eregi_replace($email_bad_array,'',$cc);
      $cc = str_replace(" ", "", $cc);
    }

    /**
     * Email Address to "Bcc" the form contents
     * separate multiple email addresses by comma
     * - for security, use this instead of using the form
     * ie: johndoe@yourdomain.com,janedoe@yourdomain.com
     * - can be set in the script or in the form as a form variable
     * @var string
     */
    if (!$bcc) {
      $bcc = '';
    } else {
      $bcc = eregi_replace($email_bad_array,'',$bcc);
      $bcc = str_replace(" ", "", $bcc);
    }

    /**
     * Subject for email that is sent to "recipient"
     * - can be set in the script or in the form as a form variable
     * @var string
     */
    if (!$subject) {
      $subject = '
    Beweberformular-Stelle:' . ' from' . $_SERVER['HTTP_HOST'];
    } else {
      $subject = eregi_replace($email_bad_array,'',$subject);
      $subject = stripslashes($subject);
    }

    /* ****************************************************************
     * Setting up PHPMailer-FE (can only be set in script)
     * ***************************************************************/

    /**
     * Value determines if the script will use the Worx Turing test
     * default is "false"
     * @var boolean
     */
    $useWorxTuring = false;

    /**
     * User PHPMailer as mail transport class
     * - can only be set in the script
     * @var string
     */
    $PHPMailerLocation = "class.phpmailer.php";

    /**
     * REQUIRED: value determines if the javascript window close will be
     * used when the default messages display after processing the form
     * - useful for POPUP style forms
     * default is "false"
     * @var boolean
     */
    $useWindowClose = true;

    /**
     * REQUIRED: IP or domain name of domains allowed to use your script
     * defaults to $_SERVER['
    HTTP_HOST']
     * - can only be set in the script
     * @var array
     */
    $referers   = array ($_SERVER['
    HTTP_HOST']);

    /**
     * Option to include System Environment Variables with form content
     * - can be set in the script or in the form as a form variable
     * Note: comment out to disable
     * @var array
     */
    if (!$env_report) {
      $env_report = array ();
      //$env_report = array ('
    REMOTE_HOST','REMOTE_USER','REMOTE_ADDR','HTTP_USER_AGENT','HTTP_REFERER');
    }

    /**
     * Use Environment Variables Report, that is email the details of the sender'
    s browser
     
    * - can only be set in the script
     
    * @var boolean
     
    */
    $useEnvRpt  false;

    /**
     * Email addresses that are banned from using the script
     * - can only be set in the script
     * @var array
     */
    $banEmails    ''//array ('*@anydomain.com', '*@otherdomain.com');

    /**
     * Defined Term, Separator (field / value separator)
     * @var static string
     */
    define("SEPARATOR", ($separator)?$separator:": ");

    /**
     * Defined Term, Newline (end of line)
     * @var static string
     */
    define("NEWLINE", ($newline)?$newline:"\n");

    /**
     * Defined Term, PHPMailer-FE Version number (for debugging mostly)
     * @var static string
     */
    define("VERSION""2.1rc3");

    /**
     * Ban List file name, fully qualified including directory
     * ie. /home/public_html/account/banlog.php
     * - can only be set in the script
     * @var string
     */
    $fileBanlist 'banlog.php';

    /**
    * Use Ban List, protect from URLs in fields containing "comments" in name
    * - can only be set in the script
    * @var boolean
    */
    $useBanlist  false;
    if ( 
    is_writable($fileBanlist) ) {
      
    $useBanlist  true;
    }

    /**
     * Redirect URL if banned or hacked or failed Worx Turing test
     * - can only be set in the script
     * @var boolean
     */
    $redirOnBan  "http://" $_SERVER['HTTP_HOST'];

    /**
     * Defines the file extensions of files that can be emailed as attachments to you
     * - can only be set in the script
     * @var array
     */
    $allowedFileTypes "doc|xls|pdf|jpg|jpeg|gif|rtf|docx";

    /* ------------ END SETTINGS - START PROCESSING -------------------- */

    // do the Worx Turing test
    if ( $useWorxTuring && isset($_POST['WorxTuringTest']) ) {
      
    session_start();
      if (
    strtoupper($_POST['WorxTuringTest']) != $_SESSION['WorxTuringTest']) {
        echo 
    "Security test failed ...<br>";
        echo 
    "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"4; URL=" $redirOnBan "\">";
        if (
    $useWindowClose) {
          echo 
    '<script language="javascript" type="text/javascript">' "\n";
          echo 
    'setTimeout("self.close()", 10 )' "\n";
          echo 
    '</script>' "\n";
        }
        exit();
      }
      
    session_destroy();
    }

    //check connect through proxy or not
    $proxydescription "";
    $remoteaddr       $_SERVER['REMOTE_ADDR'];
    $http_via         getenv('HTTP_VIA');
    $http_forwarded   getenv('HTTP_X_FORWARDED_FOR');
    $remoteport       getenv('REMOTE_PORT');
    //no proxy case or highly anonymous case
    if($http_via == NULL && $http_forwarded == NULL) {
      
    $remote $remoteaddr;
      
    $proxyip $remoteaddr;
      
    $hostname gethostbyaddr($remoteaddr);
      
    $proxyhostname gethostbyaddr($remoteaddr);
      
    $proxydescription "No Proxy or a High Anonymity Proxy";
    } else if(
    strcmp($remote$http_via) == && strcmp($http_forwarded$http_via) != 0) {
      
    //Transparent Proxy or Anonymous Proxy case
      
    $remote $http_forwarded;
      
    $proxyip $remoteaddr;
      
    $hostname gethostbyaddr($http_forwarded);
      
    $proxyhostname gethostbyaddr($remoteaddr);
      
    $proxydescription "Transparent Proxy or Anonymous Proxy";
    } else {
      
    //Highly Anonymous Proxy case
      
    $remote $remoteaddr;
      
    $proxyip $remoteaddr;
      
    $hostname gethostbyaddr($remoteaddr);
      
    $proxyhostname gethostbyaddr($remoteaddr);
      
    $proxydescription "Highly Anonymous Proxy";
    }

    $IP   $proxyip;
    $HOST $proxyhostname;
    echo 
    "IP: $IP at $HOST<hr>";

    /* uncomment to hard code IP addresses
    if ($IP   == "85.255.120.58" ||
        $IP   == "216.255.183.194" ||
        substr_count($HOST, "custblock.intercage.com") > 0 ||
        substr_count($HOST, "inhoster.com") > 0
       ) {
      echo "Submissions from your IP address are not accepted<br>";
      echo "<meta http-equiv=\"Refresh\" content=\"3; URL=http://www.google.com/\">";
      if ($useWindowClose) {
        echo '<script language="javascript" type="text/javascript">' . "\n";
        echo 'setTimeout("self.close()", 10 )' . "\n";
        echo '</script>' . "\n";
      }
      exit();
    }
    */

    /**
     * Checks that form is from an approved "referer"
     * - will exit and not proceed if referer is NOT found
     * @var array string
     */
    if ($referers) {
      
    check_referer($referers);
    }

    /**
     * Checks if "email" included in form is on banlist
     * - will exit and not proceed if email is on banlist
     */
    if ($banEmails) {
      
    check_banlist($banEmails$email);
    }

    /**
     * Sort the $_POST variables
     */
    if ($sort == "alphabetic") {
      
    uksort($_POST"strnatcasecmp");
    } elseif ((
    ereg('^order:.*,.*'$sort)) && ($list explode(','ereg_replace('^order:'''$sort)))) {
      
    $sort $list;
    }

    /**
     * 1. Convert all $_POST variables to a regular variable
     * 2. Checks all $_POSTs for URL type input
     *    - will exit and not proceed if URL type input is found
     *
     * NOTE: REQUIRED, PLEASE DO NOT CHANGE ... NEEDED TO SET VARIABLES PROPERLY
     *
     */
    foreach ($_POST as $key => $value) {
      
    $key strtolower($key);
      $
    $key addslashes(trim(utf8_urldecode($value)));
      if (
    $useBanlist && is_writable($fileBanlist)) {
        if ( !
    stristr($key'url') ) { // will only search if 'url' not found in $key
          
    $hacked FALSE;
          
    $hacked checkBannedInput($key,$value,$fileBanlist);
        }
      }
      if ( 
    $hacked === TRUE ) {
        echo 
    "Das Formular wurde aufgrund einer möglichen Spam Ataccke nicht abgesendet.<br>";
        echo 
    "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"4; URL=" $redirOnBan "\">";
        if (
    $useWindowClose) {
          echo 
    '<script language="javascript" type="text/javascript">' "\n";
          echo 
    'setTimeout("self.close()", 10 )' "\n";
          echo 
    '</script>' "\n";
        }
        exit();
      }
    }

    /**
     * Checks if the browser's IP address or Remote Host is on ban list
     * - will exit and not proceed if either is found in ban list
     */
    if ($useBanlist && is_writable($fileBanlist)) {
      
    $banned checkBanlist($fileBanlist);
      if (
    $banned) {
        echo 
    "Submissions not accepted from  ..." $IP  " / " $HOST "<br>";
        echo 
    "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"4; URL=" $redirOnBan "\">";
        if (
    $useWindowClose) {
          echo 
    '<script language="javascript" type="text/javascript">' "\n";
          echo 
    'setTimeout("self.close()", 10 )' "\n";
          echo 
    '</script>' "\n";
        }
        exit();
      }
    }

    /**
     * Determines if $_POST fields that are blank are sent in email
     * - Default is false (blanks are not included)
     * - set in he form as a form variable
     * @var boolean
     */
    if (!isset($print_blank_fields)) {
      
    $print_blank_fields true;
      }

    /**
     * Checks if "recipient" is valid email address
     * - will generate error if email is not valid
     */
    $recipient_in split(',',$recipient);
    for (
    $i=0;$i<count($recipient_in);$i++) {
      
    $recipient_to_test trim($recipient_in[$i]);
      if ( 
    _validateEmail($recipient_to_test) === FALSE ) {
        
    print_error("your <b>email address</b> is invalid");
      }
    }

    /**
     * Used to maintain compatibility with Formmail.pl and formmail.php
     */
    if ($required) {
      if (
    $require) {
        
    $require .= $required;
      } else {
        
    $require $required;
      }
    }

    /**
     * Process required fields
     */
    if ($require) {
      
    // split at commas
      
    $require ereg_replace" +"""$require);
      
    $required split(",",$require);
      for (
    $i=0;$i<count($required);$i++) {
        
    $string trim($required[$i]);
        
    // check if exists
        
    if((!(${$string})) || (!(${$string}))) {
          
    // if the missing_fields_redirect option is on: redirect them
          
    if ($missing_fields_redirect) {
            echo 
    "<meta http-equiv=\"refresh\" content=\"0;url=" $missing_fields_redirect '">';
            exit();
          }
          
    $require;
          
    $missing_field_list .= "<b>Folgende Felder sind Pflichtfelder: " $required[$i] . "</b><br>\n";
        }
      }
      
    // send error to our error function
      
    if ($missing_field_list) {
        
    print_error($missing_field_list,"fehlen");
      }
    }



    /**
     * Prepare (parse) content
     */
    $contentArray parse_form($_POST$sort);

    /**
     * Upload attachment is there is one
     */
    $attachment_name $_FILES["attachment"]["name"];
    $attachment_size $_FILES["attachment"]["size"];
    $attachment_temp $_FILES["attachment"]["tmp_name"];
    $attachment_type $_FILES["attachment"]["type"];
    $attachment_ext  explode('.'$attachment_name);
    $attachment_ext  $attachment_ext[count($attachment_ext)-1];
    if(
    stristr($allowedFileTypes$attachment_ext) === true) {
      if (
    $attachment_name) {
        if (
    $attachment_size 0) {
          if (!
    $attachment_type) {
            
    $attachment_type =  "application/unknown";
          }
          
    $content    .= "Attached File: ".$attachment_name."\n";
          
    $fp fopen($attachment_temp,  "r");
          
    $attachment_chunk fread($fpfilesize($attachment_temp));
          
    $attachment_chunk base64_encode($attachment_chunk);
          
    $attachment_chunk chunk_split($attachment_chunk);
        }
      }
    }



    /**
     * Send the $_POST variables
     */
    if (!$realname && $name) {
      
    $realname $name;
    }
    $realname eregi_replace($email_bad_array,'',$realname);

    $contentText      $content;
    $contentHTML      str_replace("\n","<br>",$content);
    $content          = array();
    $content['text']  = $contentArray['text'] . $contentText;
    $content['html']  = $contentArray['html'] . $contentHTML;

    mail_it($content$subject$email$realname$recipient);
    if (
    $send_email_copy && $email) {
      
    mail_it($content'Copy: ' $subject$email$realname$email);
    }
    if (
    file_exists($ar_file)) {
      
    $fd fopen($ar_file"rb");
      
    $ar_message fread($fdfilesize($ar_file));
      
    fclose($fd);
      
    mail_it($ar_message, ($ar_subject)?stripslashes($ar_subject):"RE: " $subject, ($ar_from)?$ar_from:$recipient$email$realname );
    }

    /**
     * Redirect (after sent) if redirect variable is set
     */
    if ($redirect) {
      echo 
    "<meta http-equiv=\"refresh\" content=\"0;url=" $redirect '">';
      if (
    $useWindowClose) {
        echo 
    '<script language="javascript" type="text/javascript">' "\n";
        echo 
    'setTimeout("self.close()", 0 )' "\n";
        echo 
    '</script>' "\n";
      }
      exit();
    } else {
      echo 
    "Vielen Dank. Ihre Daten wurden übermittelt. Wir werden uns innerhalb der nächsten Tage vorzugsweise per Email bei Ihnen melden.\n";
      echo 
    "<br><br>\n";
      if (
    $return_link_url) {
        echo 
    "<a href=\"" $return_link_url "\">";
        if (
    $return_link_title) {
          echo 
    $return_link_title;
        } else {
          echo 
    $return_link_url;
        }
        echo 
    "</a>";
        echo 
    "<br><br>\n";
      }
      echo 
    "<small>Powered by <a href=\"http://phpmailer.codeworxtech.com/\">PHPMailer-FE.php " VERSION "!</a></small>\n\n";
      echo 
    '<script language="javascript" type="text/javascript">' "\n";
      if (
    $useWindowClose) {
        echo 
    'setTimeout("self.close()", 5000 )' "\n";
      }
      echo 
    '</script>' "\n";
      exit();
    }

    /* ****************** FUNCTIONS ******************** */

    /**
     * Error processing function
     * @param string $reason
     * @param int $type
     * @return void
     */
    function print_error($reason,$type 0) {
      
    build_body($title$bgcolor$text_color$link_color$vlink_color$alink_color$style_sheet);
      
    // for missing required data
      
    if ($type == "missing") {
        if (
    $missing_field_redirect) {
          
    header("Location: $missing_field_redirect?error=$reason");
            exit();
        } else {
          
    ?>
          The form was not submitted for the following reasons:<p>
          <ul><?php
            
    echo $reason."\n";
          
    ?></ul>
          Please use your browser's back button to return to the form and try again.<?php
        
    }
      } else { 
    // every other error
        
    ?>
        The form was not submitted because of the following reasons:<p>
        <?php
      
    }
      echo 
    "<br><br>\n";
      echo 
    "<small>This form is powered by <a href=\"http://phpmailer.codeworxtech.com/\">PHPMailer-FE.php " VERSION "</a></small>\n\n";
       exit();
    }

    /**
     * Function to check the banlist
     * calls error function if banned email is found
     * @param array $banEmails
     * @param string $email
     * @return void
     */
    function check_banlist($banEmails$email) {
      if (
    count($banEmails)) {
        
    $allow true;
        foreach(
    $banEmails as $banned) {
          
    $temp explode("@"$banned);
          if (
    $temp[0] == "*") {
            
    $temp2 explode("@"$email);
            if (
    trim(strtolower($temp2[1])) == trim(strtolower($temp[1]))) {
              
    $allow false;
            }
          } else {
            if (
    trim(strtolower($email)) == trim(strtolower($banned))) {
              
    $allow false;
            }
          }
        }
      }
      if (!
    $allow) {
        
    print_error("You are using a <b>banned email address.</b>");
      }
    }

    /**
     * Function to check referer (IP or Domain of submitted $_POST)
     * calls error function if referer is NOT found
     * @param array $referers
     * @return boolean
     */
    function check_referer($referers) {
      if (
    count($referers)) {
        
    $found false;

        
    $temp explode("/",getenv("HTTP_REFERER"));
        
    $referer $temp[2];

        if (
    $referer=="") {
          
    $referer $_SERVER['HTTP_REFERER'];
          list(
    $remove,$stuff)=split('//',$referer,2);
          list(
    $home,$stuff)=split('/',$stuff,2);
          
    $referer $home;
        }

        for (
    $x=0$x count($referers); $x++) {
           if (
    eregi ($referers[$x], $referer)) {
             
    $found true;
           }
        }
        if (
    $referer == "") {
          
    $found false;
        }
        if (!
    $found) {
          
    print_error("You are coming from an <b>unauthorized domain. ($referer)</b>");
          
    error_log("[PHPMailer-FE.php] Illegal Referer. (".getenv("HTTP_REFERER").")"0);
        }
        return 
    $found;
      } else {
        return 
    true;
      }
    }

    /**
     * Function to: sort, exclude keys, and format content string
     * @param array $array
     * @param array $sort
     * @return string
     */
    function parse_form($array$sort "") {
      
    // reserved keyword array
      
    $reserved_keys[] = "alink_color";
      
    $reserved_keys[] = "bgcolor";
      
    $reserved_keys[] = "link_color";
      
    $reserved_keys[] = "MAX_FILE_SIZE";
      
    $reserved_keys[] = "missing_fields_redirect";
      
    $reserved_keys[] = "form_notice";
      
    $reserved_keys[] = "path_to_file";
      
    $reserved_keys[] = "print_blank_fields";
      
    $reserved_keys[] = "recipient";
      
    $reserved_keys[] = "redirect";
      
    $reserved_keys[] = "require";
      
    $reserved_keys[] = "required";
      
    $reserved_keys[] = "return_link_url";
      
    $reserved_keys[] = "return_link_title";
      
    $reserved_keys[] = "send";
      
    $reserved_keys[] = "sort";
      
    $reserved_keys[] = "style_sheet";
      
    $reserved_keys[] = "subject";
      
    $reserved_keys[] = "submit";
      
    $reserved_keys[] = "submit_x";
      
    $reserved_keys[] = "submit_y";
      
    $reserved_keys[] = "text_color";
      
    $reserved_keys[] = "title";
      
    $reserved_keys[] = "vlink_color";
      
    $reserved_keys[] = "WorxTuringTest";

      if (
    count($array)) {
        if (
    is_array($sort)) {
          foreach (
    $sort as $field) {
            
    $reserved_violation 0;
            for (
    $ri=0$ri<count($reserved_keys); $ri++) {
              if (
    $array[$field] == $reserved_keys[$ri]) $reserved_violation 1;
            }
            if (
    $reserved_violation != 1) {
              if (
    is_array($array[$field])) {
                for (
    $z=0;$z<count($array[$field]);$z++) {
                  
    $content['text'] .= $field.SEPARATOR.$array[$field][$z].NEWLINE;
                  
    $content['html'] .= '<tr><td align="right" style="border: 1px #E0E0E0 solid;">' $field '</td><td style="border: 1px #E0E0E0 solid;">' $array[$field][$z] . '</td></tr>';
                }
              } else {
                
    $content['text'] .= $field.SEPARATOR.$array[$field].NEWLINE;
                
    $content['html'] .= '<tr><td align="right" style="border: 1px #E0E0E0 solid;">' $field '</td><td style="border: 1px #E0E0E0 solid;">' $array[$field] . '</td></tr>';
              }
            }
          }
        }
        while (list(
    $key$val) = each($array)) {
          
    $reserved_violation 0;
          for (
    $ri=0$ri<count($reserved_keys); $ri++) {
            if (
    $key == $reserved_keys[$ri]) {
              
    $reserved_violation 1;
            }
          }
          for (
    $ri=0$ri<count($sort); $ri++) {
            if (
    $key == $sort[$ri]) {
              
    $reserved_violation 1;
            }
          }
          
    // prepare content
          
    if ($reserved_violation != 1) {
            if (
    is_array($val)) {
              for (
    $z=0;$z<count($val);$z++) {
                if ( (
    strlen($val[$z]) > 0) || $print_blank_fields ) {
                  
    $content['text'] .= $key.SEPARATOR.$val[$z].NEWLINE;
                  
    $content['html'] .= '<tr><td align="right" bgcolor="#ffffff" style="border: 1px #E0E0E0 solid;">' $key '</td><td bgcolor="#ffffff" style="border: 1px #E0E0E0 solid;">' $val[$z] . '</td></tr>';
                }
              }
            } else {
              if ( 
    strlen($val) > ) {
                
    $content['text'] .= $key.SEPARATOR.$val.NEWLINE;
                
    $content['html'] .= '<tr><td align="right" bgcolor="#ffffff" style="border: 1px #E0E0E0 solid;">' $key '</td><td bgcolor="#ffffff" style="border: 1px #E0E0E0 solid;">' $val '</td></tr>';
              }
            }
          }
        }
      }
      
    $content['html']  = '<table border="0" cellpadding="2" cellspacing="0" style="border: 1px #E0E0E0 solid;"><tr><th bgcolor="#ffffd2" style="border: 1px #E0E0E0 solid;">Form Field</td><th bgcolor="#ffffd2" style="border: 1px #E0E0E0 solid;">User Input</td></tr>'.$content['html'].'</table>';
      return 
    $content;
    }

    /**
     * Function to mail the content
     * @param string $content
     * @param string $subject
     * @param string/array $email
     * @param string/array $recipient
     * @return void
     */
    function mail_it($content$subject$email$realname$recipient) {
      global 
    $attachment_chunk$attachment_name$attachment_type$attachment_sent$attachment_temp$bcc;
      global 
    $PHPMailerLocation$fixedFromEmail$fixedFromName;

      if (
    $realname) {
        
    $sendTo $realname "<" $email ">";
      } else {
        
    $sendTo $email;
      }
      
    $ob "----=_OuterBoundary_000";
      
    $ib "----=_InnerBoundery_001";

      
    $headers  "MIME-Version: 1.0\r\n";
      if (
    $fixedFromEmail != '') {
        
    $headers .= "From: " $fixedFromEmail "\n";
      } else {
        
    $headers .= "From: " $sendTo "\n";
      }
      
    $headers .= "To: " $recipient "\n";
      
    $headers .= "Reply-To: " $sendTo "\n";
      if (
    $bcc) { $headers .= "Bcc: ".$bcc."\n"; }
      
    $headers .= "X-Priority: 1\n";
      
    $headers .= "X-Mailer: PHPMailer-FE v" VERSION " (software by codeworxtech.com)\n";
      
    $headers .= "Content-Type: multipart/mixed;\n\tboundary=\"" $ob "\"\n";
      
    $message  "This is a multi-part message in MIME format.\n";
      
    $message .= "\n--".$ob."\n";
      
    $message .= "Content-Type: multipart/alternative;\n\tboundary=\"" $ib "\"\n\n";
      
    $message .= "\n--" $ib "\n";
      
    $message .= "Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n";
      
    $message .= "Content-Transfer-Encoding: quoted-printable\n\n";
      
    $message .= $content['text'] . "\n\n";
      
    $message .= "\n--" $ib "--\n";
      if (
    $attachment_name && !$attachment_sent) {
        
    $message .= "\n--" $ob "\n";
        
    $message .= "Content-Type: $attachment_type;\n\tname=\"" $attachment_name "\"\n";
        
    $message .= "Content-Transfer-Encoding: base64\n";
        
    $message .= "Content-Disposition: attachment;\n\tfilename=\"" $attachment_name "\"\n\n";
        
    $message .= $attachment_chunk;
        
    $message .= "\n\n";
      }
      
    $message .= "\n--" $ob "--\n";
      if (
    file_exists($PHPMailerLocation)) {
        include_once(
    $PHPMailerLocation);
        
    $mail           = new PHPMailer();
        if (
    $fixedFromEmail != '') {
          
    $mail->From     $fixedFromEmail;
          
    $mail->FromName $fixedFromName;
        } else {
          
    $mail->From     $email;
          
    $mail->FromName $realname;
        }
        
    $mail->Subject  $subject;
        
    $mail->AltBody  $content['text'];
        
    $mail->MsgHTML($content['html']);
        
    $mail->AddAddress($recipient);
        if (
    $bcc) {
          if (
    count($bcc) > 1) {
            
    $bcc_in split(',',$bcc);
            foreach (
    $arr as $key => $value) {
              
    $mail->AddBcc($bcc);
            }
          } else {
            
    $mail->AddBcc($bcc);
          }
        }
        if (
    $cc) {
          if (
    count($cc) > 1) {
            
    $bcc_in split(',',$cc);
            foreach (
    $arr as $key => $value) {
              
    $mail->AddCc($cc);
            }
          } else {
            
    $mail->AddCc($cc);
          }
        }
        if (
    $attachment_name && !$attachment_sent) {
          
    $mail->AddAttachment($attachment_temp$attachment_name);
        }
        
    $mail->Send();
      } else {
        @
    mail($recipient$subject$message$headers);
      }

      if (!
    $attachment_sent) {
        
    $attachment_sent 1;
      }
    }

    /**
     * Function to build the redirect HTML page for redirect (if no redirect specified)
     * @param string $title
     * @param string $bgcolor
     * @param string $text_color
     * @param string $link_color
     * @param string $vlink_color
     * @param string $alink_color
     * @param string $style_sheet
     * @return void
     */
    function build_body($title$bgcolor$text_color$link_color$vlink_color$alink_color$style_sheet) {
      if (
    $style_sheet) {
        echo 
    "<LINK rel=STYLESHEET href=\"$style_sheet\" Type=\"text/css\">\n";
      }
      if (
    $title) {
        echo 
    "<title>$title</title>\n";
      }
      if (!
    $bgcolor) {
        
    $bgcolor "#FFFFFF";
      }
      if (!
    $text_color) {
        
    $text_color "#000000";
      }
      if (!
    $link_color) {
        
    $link_color "#0000FF";
      }
      if (!
    $vlink_color) {
        
    $vlink_color "#FF0000";
      }
      if (!
    $alink_color) {
        
    $alink_color "#000088";
      }
      if (
    $background) {
        
    $background "background=\"$background\"";
      }
      echo 
    "<body bgcolor=\"$bgcolor\" text=\"$text_color\" link=\"$link_color\" vlink=\"$vlink_color\" alink=\"$alink_color\" $background>\n\n";
    }

    /**
     * Function to decode URL including UTF8 elements
     * @param string $str
     * @return void
     */
    function utf8_urldecode($str) {
      
    $str preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str));
      return 
    html_entity_decode($str);
    }

    /**
     * Function to check the user's IP address or Remote Host is on the banlist
     * @param string $fileBanlist
     * @return boolean
     */
    function checkBanlist($fileBanlist) {
      
    // if the option is set, read the ban list and refuse to process further if IP is found
      
    $file      fopen($fileBanlist'r');
      
    $matchIP   false;
      
    $matchHOST false;
      
    $banned    false;
      while (!
    feof($file)) {
        
    $line    fgets($file);
        
    $lbits   split(','$line);
        
    $banIP   trim($lbits[0]);
        
    $banHOST trim($lbits[1]);
        if (
    $_SERVER['REMOTE_ADDR'] == $banIP) {
          
    $matchIP true;
          
    $banned  true;
        }
        if (
    gethostbyaddr($_SERVER['REMOTE_ADDR']) == $banHOST) {
          
    $matchHOST true;
          
    $banned    true;
        }

      }
      
    fclose($file);
      if (
    $banned === true) {
        return 
    true;
      } else {
        return 
    false;
      }
    }

    /**
     * Function to check for banned input on fields that contain "comment" in name
     * - will add IP / Remote Host to the ban list log if found and stop processing
     * @param string $key
     * @param string $value
     * @param string $fileBanlist
     * @return boolean
     */
    function checkBannedInput($key,$value,$fileBanlist) {
      
    $hack false;
      
    //if ( stristr($key, 'comment') ) {
      
    if ( $key != "subject" ) {
        if ( 
    stristr($value'<a href') ||
             
    stristr($value'/a>') ||
             
    stristr($value'http:') ||
             
    stristr($value'www') ) {
          
    $hack true;
          echo 
    $value " - " $key ": reached area of hyperlink<br>";
        }
      }
      if (
    $hack === true) {
        
    // ADD TO BAN LIST
        
    if (is_writable($fileBanlist)) {
          
    $handle fopen($fileBanlist'a');
          
    fwrite($handle$_SERVER['REMOTE_ADDR'] . "," gethostbyaddr($_SERVER['REMOTE_ADDR']) . "\n");
          
    fclose($handle);
        }
      }
      return 
    $hack;
    }

    /**
     * Function to validate an email address (format and MX record)
     * @param string $email
     * @return boolean
     * (returns true if email address is properly formatted and MX record exists
     */
    function _validateEmail($emailAddy) {
      
    $pattern "/^[\w-]+(\.[\w-]+)*@";
      
    $pattern .= "([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/i";
      if (
    preg_match($pattern$emailAddy)) { // valid email address
        
    $parts explode("@"$emailAddy);
        if (!
    checkdnsrr($parts[1], 'MX')) { // fails MX record check
          
    return false;
        }
      } else { 
    // fails pre_match test
        
    return false;
      }
    }

    ?>


    Ich würde mich freuen, wenn mir irgendwer helfen könnte.


    MfG,
    Nad

  • #2
    da der gepostete Coe ab einer bestimmten Stelle rot durchgefärbt ist, findet man die fehlehafte Stelle dort, wo es aufhört gemischt bunt zu sein

    $recipient = 'meine mail addi;

    Da fehlt das schließende Hochkomma.
    [PHP]if ($var != 0) {
    $var = 0;
    }[/PHP]

    Kommentar


    • #3
      PHP-Fortgeschrittene *hust*^^

      "Du bist ein Profi? Dann...
      ... hast Du min. 3 Jahre Praxis-Erfahrung mit PHP."

      Also entweder, du hast in den Jahren noch nicht viel von Fehlerbehandlung gehört bzw. hast dir keinen ordentlichen Editor zugelegt oder du hast dich im Forum verklickt

      Kommentar


      • #4
        Hallo Nad Flenders (cooler Name),

        ich verstehe nicht warum du eine abgewande Version von phpmailer verwendest? PHP Mailer an sich, kann bereits von Haus aus Dateianhänge versenden.

        Mach es doch einfach...

        - Formular
        - Upload ausführen
        - Message generieren,
        - Hochgeladene Datei phpmailer übergeben
        - Message phpmailer übergeben
        - Email senden
        - Wenn erwünscht Dateianhang löschen
        - fertig und die Email ist da inklusive Dateianhang.

        Zudem ist das auch keine Fortgeschritte Frage.

        Ich hab hier nämlich nirgends Debug ausgaben gesehen, zudem fehlt dir ein abschließendes '.
        [B]Mfg Tomtaz[/B]
        [I]"Es soll jetzt diese Erfindung geben.... Kugel oder so heißt die. Ist so eine Art Suchmaschine..." [/I]:!::shock:

        Kommentar


        • #5
          HaHaHa

          @Young Jedi
          mkay, vielleicht das Falsche Forum, aber dafür die richtige Frage.
          Ich bin klar kein Profi. Sonst hätte ich den Fehler evtl. selber gefunden. Verezih mir, dass ich falschen Forum gepostet habe.

          @Wolla

          ....im Originalen fehlt es nicht.

          @tomtaz

          Naja, der Nahme stammt nicht von mir.....

          Ich wollte auch erst den regulären phpmailer verwenden. Habe dann aber gesehen, dass es vom gleichen, hm, sagen wir Anbieter den PHP Mailer direkt für Formulare gibt. Er soll das Gleiche könne wir Phpmailer, ist jedoch bereits auf Formulare zugescchnitten und daher schlanker.
          Hier mal der Link:
          Codeworx Technologies

          Sollte ich die ganze Geschichte nochmal bei den Anfängern posten?


          Greetz,
          Nad

          Kommentar


          • #6
            Zitat von Nad Flanders Beitrag anzeigen
            Sollte ich die ganze Geschichte nochmal bei den Anfängern posten?


            Greetz,
            Nad
            Ne, wir haben hier nette Moderatoren, die verschieben dir das...
            [B]Mfg Tomtaz[/B]
            [I]"Es soll jetzt diese Erfindung geben.... Kugel oder so heißt die. Ist so eine Art Suchmaschine..." [/I]:!::shock:

            Kommentar

            Lädt...
            X