formmail / Dateianhang

Sieht ganz gut aus.
Ich denke mal die sollte so laufen.

Ich hab Dir die Funktion mal aus der Doku kopiert.
PHP:
   function quoted_printable($string)
   {
       $crlf    = "\n" ;
       $string  = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf ;
       $f[]    = '/([\000-\010\013\014\016-\037\075\177-\377])/e' ;
       $r[]    = "'=' . sprintf('%02X', ord('\\1'))" ;
       $f[]    = '/([\011\040])' . $crlf . '/e' ;
       $r[]    = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'" ;
       $string  = preg_replace($f, $r, $string) ;
       return trim(wordwrap($string, 70, ' =' . $crlf)) ;
   }
Die sollte es eigentlich tun. Hab sie aber nicht getestet.
 
hmmm
ich bekomm
Code:
Fatal error: Call to undefined function: quoted_printable() in /home/www/webxx/html/mail/email.class.php on line 77
:'(
Code:
<?php 
class email 
{ 
    var $id; 
    var $to; 
    var $subject; 
    var $body; 
    var $from; 
    var $cc; 
    var $bcc; 
    var $attachedfiles; 

function quoted_printable($string) 
   { 
       $crlf    = "\n" ; 
       $string  = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf ; 
       $f[]    = '/([\000-\010\013\014\016-\037\075\177-\377])/e' ; 
       $r[]    = "'=' . sprintf('%02X', ord('\\1'))" ; 
       $f[]    = '/([\011\040])' . $crlf . '/e' ; 
       $r[]    = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'" ; 
       $string  = preg_replace($f, $r, $string) ; 
       return trim(wordwrap($string, 70, ' =' . $crlf)) ; 
   } 

    function __construct($to,$subject,$body,$from="",$cc="",$bcc="") 
    { 
        $this->id=md5(uniqid()); 
        $this->to=$to; 
        $this->subject=$subject; 
        $this->body=$body; 
        $this->from=$from; 
        $this->cc=$cc; 
        $this->bcc=$bcc; 
        $this->attachedfiles=array(); 
    } 

    function destroy() 
    { 
        if (file_exists("mailtemp/".$this->id)) 
            { 
                for ($attachment=0;$attachment<count($this->attachedfiles);$attachment++) 
                    { 
                        unlink("mailtemp/".$this->id."/".$this->attachedfiles[$attachment]); 
                    } 
                rmdir("mailtemp/".$this->id); 
            } 
    } 

    function attachfile($tempfile,$filename) 
    { 
        if (!file_exists("mailtemp/".$this->id)) 
            { 
                mkdir("mailtemp/".$this->id); 
            } 
        move_uploaded_file($tempfile,"mailtemp/".$this->id."/".$filename); 
        $this->attachedfiles[]=$filename; 
    } 

    function removeattachment($filename) 
    { 
        unlink("mailtemp/".$this->id."/".$filename); 
        $newattachedfiles=array(); 
        for ($attachment=0;$attachment<count($this->attachedfiles);$attachment++) 
            { 
                if ($this->attachedfiles[$attachment]!=$filename) 
                    { 
                        $newattachedfiles[]=$this->attachedfiles[$attachment]; 
                    } 
            } 
        $this->attachedfiles=$newattachedfiles; 
        unset($newattachedfiles); 
    } 

    function send() 
    { 
        $body=quoted_printable($this->body); 
        $body.="\n\n"; 
        $boundary="----".$this->id; 
        $email="info@trempe3.com"; 
        $email.="Content-class: urn:content-classes:message"; 
        $email.="\nUser-Agent: Free WebMail"; 
        $email.="\nMIME-Version: 1.0"; 
        if (!empty($this->attachedfiles)) 
            { 
                $email.="\nContent-Type: multipart/mixed;\n\tboundary=\"".$boundary."\""; 
            } 
        if (!empty($this->from)) 
            { 
                $email.="\nFrom: ".$this->from; 
            } 
        if (!empty($this->cc)) 
            { 
                $email.="\nCc: ".$this->cc; 
            } 
        if (!empty($this->bcc)) 
            { 
                $email.="\nBcc: ".$this->bcc; 
            } 
        $email.="\nX-Priority: 3 (Normal)"; 
        $email.="\nImportance: Normal"; 
        if (!empty($this->attachedfiles)) 
            { 
                $email.="\n\n--".$boundary; 
            } 
        $email.="\nContent-Type: text/plain;\n\tcharset=\"iso-8859-1\""; 
        $email.="\nContent-Transfer-Encoding: quoted-printable"; 
        $email.="\nContent-Disposition: inline"; 
        $email.="\n\n".$body; 
        if (!empty($this->attachedfiles)) 
            { 
                $email.="\n\n--".$boundary; 
            } 
        for ($attachment=0;$attachment<count($this->attachedfiles);$attachment++) 
            { 
                $file=fopen("mailtemp/".$this->id."/".$this->attachedfiles[$attachment],"r"); 
                $content=fread($file,filesize("mailtemp/".$this->id."/".$this->attachedfiles[$attachment])); 
                fclose($file); 
                $encodedfile=chunk_split(base64_encode($content)); 
                $email.="\nContent-Type: application/octet-stream;\n\tname=\"".$this->attachedfiles[$attachment]."\""; 
                $email.="\nContent-Transfer-Encoding: base64"; 
                $email.="\nContent-Description: ".$this->attachedfiles[$attachment]; 
                $email.="\nContent-Disposition: attachment;\n\tfilename=\"".$this->attachedfiles[$attachment]."\""; 
                $email.="\n\n".$encodedfile."\n\n--".$boundary; 
            } 
        if (!empty($this->attachedfiles)) 
            { 
                $email.="--"; 
            } 
        mail($this->to,$this->subject,"",$email); 
    } 
} 

function mailstring($mailobject) 
{ 
    return rawurlencode(serialize($mailobject)); 
} 

function mailobject($mailstring) 
{ 
    return unserialize(stripslashes(rawurldecode($mailstring))); 
} 
?>
 
Also...
Es hat grad irgentwie gefunzt ^^ *g*

Aberrrr
1.) Ich hab kein Anhang mit bekommen.
2.) Der absender ist irgentwie nicht so korekt.
Code:
Absender:
www-data <www-data@server64.xxx.de>

Mein email.class
Code:
<?php 
class email 
{ 
    var $id; 
    var $to; 
    var $subject; 
    var $body; 
    var $from; 
    var $cc; 
    var $bcc; 
    var $attachedfiles; 

function quoted_printable($string) 
   { 
       $crlf    = "\n" ; 
       $string  = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf ; 
       $f[]    = '/([\000-\010\013\014\016-\037\075\177-\377])/e' ; 
       $r[]    = "'=' . sprintf('%02X', ord('\\1'))" ; 
       $f[]    = '/([\011\040])' . $crlf . '/e' ; 
       $r[]    = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'" ; 
       $string  = preg_replace($f, $r, $string) ; 
       return trim(wordwrap($string, 70, ' =' . $crlf)) ; 
   } 

    function __construct($to,$subject,$body,$from="",$cc="",$bcc="") 
    { 
        $this->id=md5(uniqid()); 
        $this->to=$to; 
        $this->subject=$subject; 
        $this->body=$body; 
        $this->from=$from; 
        $this->cc=$cc; 
        $this->bcc=$bcc; 
        $this->attachedfiles=array(); 
    } 

    function destroy() 
    { 
        if (file_exists("mailtemp/".$this->id)) 
            { 
                for ($attachment=0;$attachment<count($this->attachedfiles);$attachment++) 
                    { 
                        unlink("mailtemp/".$this->id."/".$this->attachedfiles[$attachment]); 
                    } 
                rmdir("mailtemp/".$this->id); 
            } 
    } 

    function attachfile($tempfile,$filename) 
    { 
        if (!file_exists("mailtemp/".$this->id)) 
            { 
                mkdir("mailtemp/".$this->id); 
            } 
        move_uploaded_file($tempfile,"mailtemp/".$this->id."/".$filename); 
        $this->attachedfiles[]=$filename; 
    } 

    function removeattachment($filename) 
    { 
        unlink("mailtemp/".$this->id."/".$filename); 
        $newattachedfiles=array(); 
        for ($attachment=0;$attachment<count($this->attachedfiles);$attachment++) 
            { 
                if ($this->attachedfiles[$attachment]!=$filename) 
                    { 
                        $newattachedfiles[]=$this->attachedfiles[$attachment]; 
                    } 
            } 
        $this->attachedfiles=$newattachedfiles; 
        unset($newattachedfiles); 
    } 

    function send() 
    { 
        $body=$this->quoted_printable($this->body); 
        $body.="\n\n"; 
        $boundary="----".$this->id; 
        $email=""; 
        $email.="Content-class: urn:content-classes:message"; 
        $email.="\nUser-Agent: Free WebMail"; 
        $email.="\nMIME-Version: 1.0"; 
        if (!empty($this->attachedfiles)) 
            { 
                $email.="\nContent-Type: multipart/mixed;\n\tboundary=\"".$boundary."\""; 
            } 
        if (!empty($this->from)) 
            { 
                $email.="\nFrom: ".$this->from; 
            } 
        if (!empty($this->cc)) 
            { 
                $email.="\nCc: ".$this->cc; 
            } 
        if (!empty($this->bcc)) 
            { 
                $email.="\nBcc: ".$this->bcc; 
            } 
        $email.="\nX-Priority: 3 (Normal)"; 
        $email.="\nImportance: Normal"; 
        if (!empty($this->attachedfiles)) 
            { 
                $email.="\n\n--".$boundary; 
            } 
        $email.="\nContent-Type: text/plain;\n\tcharset=\"iso-8859-1\""; 
        $email.="\nContent-Transfer-Encoding: quoted-printable"; 
        $email.="\nContent-Disposition: inline"; 
        $email.="\n\n".$body; 
        if (!empty($this->attachedfiles)) 
            { 
                $email.="\n\n--".$boundary; 
            } 
        for ($attachment=0;$attachment<count($this->attachedfiles);$attachment++) 
            { 
                $file=fopen("mailtemp/".$this->id."/".$this->attachedfiles[$attachment],"r"); 
                $content=fread($file,filesize("mailtemp/".$this->id."/".$this->attachedfiles[$attachment])); 
                fclose($file); 
                $encodedfile=chunk_split(base64_encode($content)); 
                $email.="\nContent-Type: application/octet-stream;\n\tname=\"".$this->attachedfiles[$attachment]."\""; 
                $email.="\nContent-Transfer-Encoding: base64"; 
                $email.="\nContent-Description: ".$this->attachedfiles[$attachment]; 
                $email.="\nContent-Disposition: attachment;\n\tfilename=\"".$this->attachedfiles[$attachment]."\""; 
                $email.="\n\n".$encodedfile."\n\n--".$boundary; 
            } 
        if (!empty($this->attachedfiles)) 
            { 
                $email.="--"; 
            } 
        mail($this->to,$this->subject,"",$email); 
    } 
} 

function mailstring($mailobject) 
{ 
    return rawurlencode(serialize($mailobject)); 
} 

function mailobject($mailstring) 
{ 
    return unserialize(stripslashes(rawurldecode($mailstring))); 
} 
?>

mein sendmail.php
Code:
<?php 
require("email.class.php"); 
if ((isset($_POST['sendmail'])) || (isset($_POST['attachfile'])) || (isset($_POST['removeattachment']))) 
    { 
        if (isset($_POST['mailto'])) 
            { 
                $mailto=$_POST['mailto']; 
            } 
        else 
            { 
                $mailto=""; 
            } 
        if (isset($_POST['subject'])) 
            { 
                $subject=$_POST['subject']; 
            } 
        else 
            { 
                $subject=""; 
            } 
        if (isset($_POST['message'])) 
            { 
                $body=$_POST['message']; 
            } 
        else 
            { 
                $body=""; 
            } 
        if (!isset($_POST['mail'])) 
            { 
                $mail=new email($mailto,$subject,$body,"info@trempe3.com"); 
            } 
        else 
            { 
                $mail=mailobject($_POST['mail']); 
                if ($mail->to!=$mailto) 
                    { 
                        $mail->to=$mailto; 
                    } 
                if ($mail->subject!=$subject) 
                    { 
                        $mail->subject=$subject; 
                    } 
                if ($mail->body!=$body) 
                    { 
                        $mail->body=$body; 
                    } 
            } 
        if (isset($_POST['attachfile'])) 
            { 
                if ($_FILES['uploadfile']['size']>0) 
                    { 
                        $mail->attachfile($_FILES['uploadfile']['tmp_name'],$_FILES['uploadfile']['name']); 
                    } 
            } 
        if (isset($_POST['removeattachment'])) 
            { 
                $postkeys=array_keys($_POST); 
                for ($keycount=0;$keycount<count($postkeys);$keycount++) 
                    { 
                        if (substr($postkeys[$keycount],0,13)=="delattachment") 
                            { 
                                $mail->removeattachment($_POST[$postkeys[$keycount]]); 
                            } 
                    } 
            } 
        if (isset($_POST['sendmail'])) 
            { 
                $mail->send(); 
                $mail->destroy(); 
                unset($mail); 
            } 
    } 
echo '<html>'; 
echo '<body>'; 
echo '<form method="post" action="sendmail.php" enctype="multipart/form-data">'; 
echo 'Recipient:'; 
echo '<input type="text" name="mailto"'; 
if (isset($mail)) 
    { 
        echo ' value="'.$mail->to.'"'; 
    } 
echo '><br>'; 
echo 'Subject:'; 
echo '<input type="text" name="subject"'; 
if (isset($mail)) 
    { 
        echo 'value="'.$subject.'"'; 
    } 
echo '><br>'; 
echo '<textarea name="message">'; 
if (isset($mail)) 
    { 
        echo $mail->body; 
    } 
echo '</textarea><br>'; 
if (isset($mail)) 
    { 
        for ($attachment=0;$attachment<count($mail->attachedfiles);$attachment++) 
            { 
                echo '<input type="hidden" name="attachment'.$attachment.'" value="'.$mail->attachedfiles[$attachment].'">'; 
                echo '<input type="checkbox" name="delattachment'.$attachment.'" value="'.$mail->attachedfiles[$attachment].'">'.$mail->attachedfiles[$attachment].'<br>'; 
            } 
        if (count($mail->attachedfiles)>0) 
            { 
                echo '<input type="submit" name="removeattachment" value="Remove selected attachments"><br>'; 
            } 
    } 
echo '<input type="file" name="uploadfile">'; 
echo '<input type="submit" name="attachfile" value="Attach file"><br>'; 
echo '<input type="submit" name="sendmail" value="Send eMail">'; 
if (isset($mail)) 
    { 
        echo '<input type="hidden" name="mail" value="'.mailstring($mail).'">'; 
    } 
echo '</form>'; 
echo '</body>'; 
echo '</html>'; 
?>

bei mein 2,3,4,5 versuch kahm dan kein mail mehr ?:-S warum *g*
 
Sorry das ich so spät antworte ^^ musste schnell weg.!

Es gibt kein fehler keins von beiden dateien :-/
 
und reptiler..
Eigentlich ist das teil nicht so das was ich suche ^^

Den das was ich will ist das, das man die file nicht hochladet...
Sondern, das ein DATEI aus meiner server bei SUBMIT auf sein E-Mail Zugeschickt wird...
IN (hidde) so zu sagen. :)

ich hab den code jetzt mal geändertn, wenn du guggst, wirst du sehen das das mail nicht an mich.! sondern an ihm selbst wieder zurück geht nur eben mit diesem datei :D
PHP:
<?php
$admin = "$row['fmail']"; 
$subject = "Ihre E-Mail an $row['firma']";
$message.="$row['mailres']"; 

mail($mail,$subject,$message,"From: $admin"); 

?>
 
Das File soll also nicht mit dem Mail-Script hochgeladen werden und liegt schon auf dem Server?

Ist doch kein Problem, dann musst Du das Script einfach nur ein wenig anpassen.
 
Zurück