<?php
function mail_att($to, $cc, $subject, $message, $sender, $sender_email, $reply_email, $dateien) {   
#    session_start();
#    $sid= session_id();

    $absender = $sender."<".$sender_email.">";
    require_once('../mail/htmlMimeMail5.php');
    $mail = new htmlMimeMail5();

    /**
    * Set the from address of the email
    */
    
    $mail->setFrom($absender);
    
    /**
    * Set the subject of the email
    */
    $mail->setSubject($subject);
    
    /**
    * Set high priority for the email. This can also be:
    * high/normal/low/1/3/5
    */
    $mail->setPriority('normal');

    /**
    * Set the text of the Email
    */
    #$mail->setText('Dies ist der Text der Email');

    /**
    * Set the HTML of the email. Any embedded images will be automatically found as long as you have added them
    * using addEmbeddedImage() as below.
    */
    $mail->setHTML("$message");

#    $mail->setTextCharset('UTF-8');
#    $mail->setTextEncoding('base64');
#    $mail->setHTMLCharset('UTF-8');
#    $mail->setHTMLEncoding('UTF-8');
#    $mail->setHeadCharset('UTF-8');
    
    
    /**
    * Set the delivery receipt of the email. This should be an email address that the receipt should be sent to.
    * You are NOT guaranteed to receive this receipt - it is dependent on the receiver.
    */
    $mail->setReceipt($reply_email);
    
    /**
    * Add an embedded image. The path is the file path to the image.
    */
    #$mail->addEmbeddedImage(new fileEmbeddedImage('background.gif'));
    
    /**
    * Add an attachment to the email.
    */
    # Die Zeile kann auch mehrfach gesetzt werden. Zb. mehrere uploads aus array
    $mail->addAttachment(new fileAttachment($dateien));

    /**
    * Send the email. Pass the method an array of recipients.
    */
    $address = $to;
    
    if($cc != ''){
      $mail->setCc($cc);
    }

    $result  = $mail->send(array($address));
    #return true;
    return $result;
}
 
//Aufruf der Funktion, Versand von 1 Datei
#mail_att("Empfaenger@domain.de", "Betreff", "Euer Nachrichtentext", "Absendername", "absender@domain.de", "antwortadresse@domain.de", "datei.zip");
 
//Versand mehrerer Dateien, die sich im Unterordner befinden:
#$dateien = array("pfad/zu/datei1.zip", "pfad/zu/datei2.png");
#mail_att("Empfaenger@domain.de", "Betreff", "Euer Nachrichtentext", "Absendername", "absender@domain.de", "antwortadresse@domain.de", $dateien);
 
//Dateien vor dem Versenden umbennen
#$dateien = array("pfad/zu/alterName.zip" => "neuerName.zip");
#mail_att("Empfaenger@domain.de", "Betreff", "Euer Nachrichtentext", "Absendername", "absender@domain.de", "antwortadresse@domain.de", $dateien);
 
?>