Results 1 to 2 of 2

Thread: MIME: Problem with boundaries

  1. #1
    Join Date
    May 2004
    Location
    MI
    Posts
    32

    MIME: Problem with boundaries

    My code doesn't seem to be recognizing my boundaries.
    Am i not seeing something? Everything else works fine.

    PHP Code:
    <?php 

    $to 
    "dgudenau@larosaequip.com"
    $subject "Drawing"
    $message "message"

    $semi_rand md5(time()); 
    $mime_boundary "==Multipart_Boundary_x{$semi_rand}x"
    $headers .= "\MIME-Version: 1.0\n" ."Content-Type: multipart/mixed;\n" 
                  
    " boundary=\"{$mime_boundary}\""
    $headers .= "i dont read this in the email"

    $headers .= "--{$mime_boundary}\n"
    $headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"
    $headers .= "Content-Transfer-Encoding: 7bit\r\n"
    $headers .= "but i got here, i do read this in email"."\r\n"



    $file_array = array(0=>array('file'=>'/dwf.gif'
    'mimetype'=>'image/gif'
    'filename'=>'myfile.gif')); 

    foreach(
    $file_array as $val

    $file fopen($val['file'],'rb'); 
    $data fread($file,filesize($val['file'])); 
    fclose($file); 

    $headers .= "--{$mime_boundary}\n"
    $headers .= "Content-Type: {$val['mimetype']}; ""name=\"{$val['filename']}\"\r\n"
    $headers .= "Content-Transfer-Encoding: ""base64\n"
    $headers .= "Content-Disposition: attachment\r\n"
    $headers .= chunk_split(base64_encode($data)); 


    $headers .= "--{$mime_boundary}--\r\n"

    if(!
    mail($to$subject$message$headers)) 

    echo 
    "Error: mail() function failed!"


    ?>
    My email reads "but i got here, i do read this in email" and then "--==Multipart_Boundary.........."

    It understands the first boundary, but not the second one.

    My phpinfo() says mime_magic support is enabled too (although i dont know what that means).

    Thanks, Dan

  2. #2
    Join Date
    May 2004
    Location
    MI
    Posts
    32

    [B]ignore that first post[/B]

    This is working code for just text:
    PHP Code:
    <?php 

    $to 
    "dgudenau@larosaequip.com"
    $subject "Drawing"
    $message "there"
    $headers "MIME-Version: 1.0\r\n";

    $headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"
    $headers .= "Content-Transfer-Encoding: 7bit\r\n"
    $headers .= "talking some message\r\n"


    mail($to$subject$message$headers)

    ?>
    This is working code for just an image attachment:
    PHP Code:
    <?php 

    $to 
    "dgudenau@larosaequip.com"
    $subject "Drawing"
    $message "message"
    $headers "MIME-Version: 1.0\r\n";

    $file_array = array(0=>array('file'=>'/dwf.gif'
    'mimetype'=>'image/gif'
    'filename'=>'myfile.gif')); 

    foreach(
    $file_array as $val

    $file fopen($val['file'],'rb'); 
    $data fread($file,filesize($val['file'])); 
    fclose($file);

    $headers .= "Content-Type: image/gif; name=myfile\r\n"
    $headers .= "Content-Transfer-Encoding: base64\r\n"
    $headers .= "Content-Disposition: attachment\r\n"
    $headers .= chunk_split(base64_encode($data)); 
    }

    mail($to$subject$message$headers)

    ?>
    Now, i cant figure out how to create the multipart/mixed mail.

    After the MIME-Version header i've added line:

    $headers .= "Content-Type: multipart/mixed; boundary=\"12345\"\r\n";

    Then before the individual content-type headers i've added line:

    $headers .= "--12345\r\n";

    Finally before i call the mail function i've added line:

    $headers .= "--12345--\r\n";

    This sends me an email with no message and a text file containing the first five letters of my $message variable (messa).

    Sorry about the first sloppy post.

    Help me.....thank you...... dan

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •