Jump to content

Good php to mail with attachment script


take3

Recommended Posts

My first post!

Im sorry it has to be a question..  :-[ But im also sharing!

 

I found a great php to mail script with attachment. I added it as a text file for if ur intrested in the whole code.

Its really easy for adding to your form and has a great way of posting errors.

 

Now my question:

The script works great with 1 attachment but how do i add a second attachment?

I tried so many things but how hard can it be?

 

Lets say this is a part of your html to upload your files:

 

<html>

<body>

<form method=post" class="appnitro" action="<?php echo basename($_SERVER["PHP_SELF]); ?>" enctype="multipart/form-data">

<li id="li_8" >

<label class="description" for="element_8">Upload your logo </label>

<div>

<input name="probe" class="element file" type="file"/> <?php if (isset($_POST['probe'])) echo htmlentities(stripslashes($_POST['probe'])); else echo ""; ?>

</div> <p class="guidelines" id="guide_8"><small>Upload your logo here. there is a max of 1 mb</small></p>

</li> <li id="li_9" >

<label class="description" for="element_9">Upload foto 1 </label>

<div>

<input name="probe2" class="element file" type="file"/> <?php if (isset($_POST['probe2'])) echo htmlentities(stripslashes($_POST['probe2'])); else echo ""; ?>

</div> <p class="guidelines" id="guide_9"><small>Upload your logo here. there is a max of 1 mb</small></p>

</li>

</form>

</body>

</html>

 

Heres a part of the php processing

 

   

// if attachment, MIME-Mail:

    if (isset($_FILES['probe']['name']) && trim($_FILES['probe']['name']) != "")

     {

      // read and encode file:

      $datei_content = fread(fopen($_FILES['probe']['tmp_name'],"r"),filesize($_FILES['probe']['tmp_name']));

      $datei_content = chunk_split(base64_encode($datei_content),76,"\n");


//? encode a second file here?



      // Boundary:

      $boundary = md5(uniqid(rand()));




  // Attachment:

      $mail_header .= "\n--".$boundary;

      $mail_header .= "\nContent-Type: ".$_FILES['probe']['type']."; name=\"".$_FILES['probe']['name']."\"";

      $mail_header .= "\nContent-Transfer-Encoding: base64";

      $mail_header .= "\nContent-Disposition: attachment; filename=\"".$_FILES['probe']['name']."\"";

      $mail_header .= "\n\n".$datei_content;


//? attach a second file here?




  // End:

      $mail_header .= "\n--".$boundary."--";



 

Cant i duplicate the encoding and attaching and rename? what am i missing here?

Can someone please help me out here?

 

Tnx.

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.