Ankündigung

Einklappen
Keine Ankündigung bisher.

Mail Problem mit Anhang

Einklappen

Neue Werbung 2019

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

  • Mail Problem mit Anhang

    Hi @ all,

    Ich habe für meine Neue Version meine FormMail Klasse jetzt noch das Datein schicken mit rein gebastelt. Nun ich das meine Sendmail funktion.

    PHP-Code:
    function send_mail($an, $von, $titel, $type){
    $type=strtolower($type);
    if(
    $type != 'html' AND $type != 'text') $this->err('Falscher Mail Typ! Bitte html oder text');
            
    if(
    $this->mail){
        
    // HTML ergänzuung Zum deaktivieren einfach auskommentieren
        
    $this->mail['html'] = "<html><head>
        <style type=\"text/css\">\n
        .key {font-family: Verdana; color:black; font-size: 11px; padding-right:5px;}\n
        .data {font-family: Verdana; color:grey; font-size: 12px;}\n
        </style>\n
        </head><body>"
    .$this->mail['html']."</body></html>";
        
    //*/
        
        
    $headers = array();
        if(
    $type == 'html'){
            
    $headers['mime-version'] = "MIME-Version: 1.0";
            
    $headers['content-type'] = "Content-type: text/html; charset=iso-8859-1\n";
            
    $headers['from'] = "From: ".$von."\n";
        }else{ 
    // if else
            
    $headers['mime-version'] = "MIME-Version: 1.0\n";
            
    $headers['content-type'] = "Content-type: text/plain; charset=iso-8859-1\n";
            
    $headers['from'] = "From: ".$von."\n";                
        } 
    // if
        
        
    if($this->option['file_name']){
            
            
    $tempi = $this->mail[$type];
            
            
    $msgtmp = "--FormMail\n";
            
    $msgtmp .= "Content-type: text/plain; name=\"".$this->option['file_name']."\"\n";
            
    $msgtmp .= "Content-transfer-encoding: base64\n\n";
            
    $msgtmp .= chunk_split(base64_encode($this->getFile($this->option['file_tmp'].$this->option['file_name'])))."\n\n";
            
            
    $this->mail[$type] = "--FormMail\n";
            
    $this->mail[$type] .= $headers['content-type'] . "\n";
            
    //$this->mail[$type] .= $msg .= "Content-Transfer-Encoding: 8bit\n\n";
            
    $this->mail[$type] .= $tempi . "\n\n";
            
            
    $headers['content-type'] = "Content-type: multipart/mixed; boundary=\"FormMail\"";
            
            
    $this->mail[$type] .= $msgtmp . "\n\n";
            
    $this->mail[$type] .= "--FormMail--";
        } 
    // if        
        
        
    $header = "";
        foreach(
    $headers as $value) {
            
    $header .= $value . "\n";
        } 
    // foreach
        
        
    if(!is_array($an)){
            
    $arr = explode(',', $an);
            
    $an = array();
            for(
    $b = 0; $b < sizeof($arr); $b++) // for
                
    if($arr[$b] != "") array_push($an, trim($arr[$b]));
        } 
    // if
        
        
    for($a = 0; $a < sizeof($an); $a++){
            if(@
    mail($an[$a],$titel,$this->mail[$type],$header))
                
    $back = true;
            else 
    // if
                
    $back = false;
        } 
    // for
        
        
    return $back;
    }else 
    $this->err('Bitte vor send_mail noch gen_mail aufrufen!');
    } 
    // function 
    Nun ist das Problem das der Anhang beim Outlook-Express noch so komisch ausgegeben wird .... wenn ich das ganze aber z.B. an Outlook sende ist es ganz normal. Stimmt da irgentwas mit den headers nicht?

    PS: getFile() Gibt die Datei zurück
    $this->mail[$type] ist der Mail-text

    MFG Tim[/code]

  • #2
    Hab was dazu gefunden. Wenn Du mit "komisch aussehen" das Gleiche meinst wie ich - ich habe mit untenstehendem Text mein Problem seinerzeit gelöst bekommen...

    Re: problem with mail() & ms outlook
    Quelle: http://www.zend.com/zend/spotlight/s...0&view=1#notes

    ...You need one blank line (two newlines "\n\n") between the email header and body as per the RFC 822.

    The problem is apparently because there are two carriage returns ("\r\r\n") before and after the relevant Mime headers, which Outlook then interprets the extra "\r" as an extra blank line which puts the Mime headers into the body so the entire email get interpreted as if it has no mime headers (i.e. just text).

    The problem also manifests in Eudora, if you view all the headers, you see the last character of each mime header line is doubled, e.g. "text/plain" becomes "text/plainn". This is apparently Eudora's way of saying their is an double "\r".

    I verified the double "\r" by POPing an email sent with mail() using telnet and saving to a raw log file.

    So what is causing the double "\r"? I have verified that I am not inputting double "\r" to mail() so and mail() is not making double "\r" for the other non-mime extra headers, such as "From:", "Reply-To:". It is making double "\r" for "Date:" also.

    So my best guess is that either mail() or the SMTP server is doing it for headers it does not recognize. My guess is PHP mail() code has this bug.

    I am going to try to work around the problem by only putting "\r\n" between "From:", "Reply-To:", "Cc:", and "Bcc:", and then use only "\n" between other extra headers I input to mail().

    If I forget to report back here that it fixed the problem, then assume the work around did work.

    Kommentar


    • #3
      werde ich mir morgen mal anschaun...
      danke

      Kommentar

      Lädt...
      X