Jump to content

Sending email having 5 image attachments.


laflair13

Recommended Posts

Hey All,

 

I am having issues understanding how this works. I am trying to do a quote and send out 5 images of the product. I cannot seem to get how I get the images sent with the email.

 

If anyone can take a look I would greatly appreciate it.

 

PHP

 

<?php

    $email = $_POST ['email'];
    $quote = $_POST ['quote'];
    $item = $_POST ['item'];
    $inventory = $_POST ['inventory'];
    $category = $_POST ['category'];
    $manu = $_POST ['manu'];
    $model = $_POST ['model'];
    $condition = $_POST ['condition'];
    $dimension = $_POST ['dimension'];
    $desc = $_POST ['desc'];
    $skidprice = $_POST ['skidprice'];
    $unitprice = $_POST ['unitprice'];
    $totalprice = $_POST ['totalprice'];
    $img1 = $_POST ['img1'];
    $img2 = $_POST ['img2'];
    $img3 = $_POST ['img3'];
    $img4 = $_POST ['img4'];
    $img5 = $_POST ['img5'];
    
    
    



    
//Get the uploaded file information
$name_of_uploaded_file =
    basename($_FILES['uploaded_file']['name']);
//get the file extension of the file
$type_of_uploaded_file =
    substr($name_of_uploaded_file,
    strrpos($name_of_uploaded_file, '.') + 1);
$size_of_uploaded_file =
    $_FILES["uploaded_file"]["size"]/1024;//size in KBs
    
//Validations
if($size_of_uploaded_file > $max_allowed_file_size )
{
  $errors .= "\n Size of file should be less than $max_allowed_file_size";
}
//------ Validate the file extension -----
$allowed_ext = false;
for($i=0; $i<sizeof($allowed_extensions); $i++)
{
  if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0)
  {
    $allowed_ext = true;
  }
}
if(!$allowed_ext)
{
  $errors .= "\n The uploaded file is not supported file type. ".
  " Only the following file types are supported: ".implode(',',$allowed_extensions);
}


//copy the temp. uploaded file to uploads folder
$path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;
$tmp_path = $_FILES["uploaded_file"]["tmp_name"];
if(is_uploaded_file($tmp_path))
{
  if(!copy($tmp_path,$path_of_uploaded_file))
  {
    $errors .= '\n error while copying the uploaded file';
  }
}
    
    
    
    // Always set content-type when sending HTML email
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

    // More headers
    $headers .= 'From: All Food Equipment<sales@allfoodequip.com>' . "\r\n";

    $headers .= "Message-ID: <".$now." sales@".$_SERVER['SERVER_NAME'].">\r\n";
    $headers .= "X-Mailer: PHP v".phpversion()."\r\n";         

    $subject = "Your All Food Equip Quote";
    
    $msg = 
            "    
            <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">
<html>
<head><link href=\"http://www.allfoodequip.com/admin/quote/style.css\" rel=\"stylesheet\" type=\"text/css\"></head>
<body>
<div id=\"container\" style=\"width:960px;
    height:auto;
    margin:0 auto;
    border-right: 2px solid #666;
    border-left: 2px solid #666;\">
<div id=\"header\"       style=\"background-image:url(http://www.allfoodequip.com/admin/quote/images/banner_bg.jpg);
    width:100%;
    height:149px;\"></div>
<!--Closes header-->
<div id=\"subHead\" 
style=\"background-image:url(http://www.allfoodequip.com/admin/quote/images/menu_bg.jpg);
    width:100%;
    height:42px;\"></div>
<!--closes subHead-->
<div class=\"contents\" style=\"background:#f2f1f1;
    padding-right: 25px;
    padding-left: 25px;\">
  <h1 style=\"margin:0px;padding:10px 0 5px;font-size:18px;\">Your All Food Equipment Quote:</h1>
  <table width=\"700\" border=\"0\" class=\"table\" style=\"padding:0px 0px 15px;\">
<tr>
<td width=\"119\">Quote #:......................................................... </td>
      <td width=\"208\">$quote</td>
    </tr>
<tr>
<td>Item:..............................................................</td>
      <td>$item</td>
    </tr>
<tr>
<td>Inventory:.......................................................</td>
      <td>$inventory</td>
    </tr>
<tr>
<td>Category:.......................................................</td>
      <td>$category</td>
    </tr>
<tr>
<td>Manufacturer:.................................................</td>
      <td>$manu</td>
    </tr>
<tr>
<td>Model:...........................................................</td>
      <td>$model</td>
    </tr>
<tr>
<td>Condition:......................................................</td>
      <td>$condition</td>
    </tr>
<tr>
<td>Dimension:....................................................</td>
      <td>$dimension</td>
    </tr>
<tr>
<td>Description:...................................................</td>
      <td>$desc</td>
    </tr>
    <br>
<tr>
<td><b>Skid Price:</b>.................................................</td>
      <td><b>$skidprice</b></td>
    </tr>
<tr>
<td><b>Unit Price:</b>.................................................</td>
      <td><b>$unitprice</b></td>
    </tr>
<tr>
<td><b>Total Price:</b>................................................</td>
      <td><b>$totalprice</b></td>
    </tr>
</table>
<div class=\"t_middle\"> <img name=\"Img\" src=\"$img1\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"><img name=\"Img\" src=\"$img2\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"><img name=\"Img\" src=\"$img3\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"><img name=\"Img\" src=\"$img4\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"><img name=\"Img\" src=\"$img5\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\">
</div>

  <div class=\"break\" style=\"padding: 15px 0px;
    width:100%;\"><hr></div>
<!--break-->
  <!--close t_middle-->

  <div class=\"contactUs\">
    <p style=\"color:#650035;\">How to contact us:</p>
    <ul class=\"contact_list\" style=\"margin:0px;padding:0px;color:#650035;line-height:25px;padding-bottom:30px;list-style:none;\">
<li>Visit us Online: www.allfoodequip.com</li>
      <li>Contact: Dino Roberts</li>
      <li>Direct Line: 615-788-2953 </li>
      <li>Email: dino@allfoodequip.com</li>
    </ul>
<ul class=\"contact_list\" style=\"margin:0px;padding:0px;color:#650035;line-height:25px;padding-bottom:30px;list-style:none;\">
<li>All Food Equipment</li>
      <li>1240 Industrial Park Road</li>
      <li>Columbia, TN 38401</li>
      <li>Main Office: 931-490-1977</li>
    </ul>
</div>
  <p style=\"font-size:14px;color:#333;\">TERMS & CONDITIONS: </p>
  
</div>
<!--close m_disc-->

<div id=\"footer\" style=\"clear: both;
    width: 100%;
    padding: 20px 0 20px 0;
    text-align: center;
    border-top: 1px solid #8b8a8b;
    background: #343233 url(http://www.allfoodequip.com/admin/quote/images/footer.jpg) no-repeat;\">
  <ul class=\"footer_list\" style=\"margin:0px;padding:0px;list-style:none;\">
<li style=\"padding: 0 10px;
    display: inline;
    border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com\" style=\"color: #cccccc;
    text-decoration: none;\">Home</a></li>
    <li style=\"padding: 0 10px;
    display: inline;
    border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com/new-equipment.php\" style=\"color: #cccccc;
    text-decoration: none;\">New Equipment</a></li>
    <li style=\"padding: 0 10px;
    display: inline;
    border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com/used-equipment.php\" style=\"color: #cccccc;
    text-decoration: none;\">Used Equipment</a></li>
    <li style=\"padding: 0 10px;
    display: inline;
    border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com/services.php\" style=\"color: #cccccc;
    text-decoration: none;\">Services</a></li>
    <li style=\"padding: 0 10px;
    display: inline;
    border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com/about-us.php\" style=\"color: #cccccc;
    text-decoration: none;\">About Us</a></li>
    <li class=\"last\" style=\"padding:0 10px;display:inline;border-right:none;\"><a href=\"http://www.allfoodequip.com/contact-us.php\" style=\"color: #cccccc;
    text-decoration: none;\">Contact Us</a></li>
  </ul>
<div class=\"margin_bottom_10\"></div><br>
  <span style=\"color:#FFF;\">Copyright © 2010 </span> - <a href=\"http://www.allfoodequip.com\"><font color=\"#FFFFCC\">All Food Equipment</font></a>
  <div class=\"margin_bottom_10\"></div>
  <!-- end of footer --> 

</div>
<!--container-->

</div>
</body>
</html>
";
            
    // MAIL SUBJECT
     $subject = "Your All Food Equip Quote";
    // TO MAIL ADDRESS
    $to="$email";
    
    

mail($to, $subject, $msg, $headers);




// Redirect
header("Location: Admin.php?Msg=Sent");

?>

 

 

Heres the HTML side of it.

   <label for="img1">Image 1:</label>
<input type="hidden" name="MAX_FILE_SIZE" value="2500000"> <input type="file" name="img1">


<label for="img2">Image 2:</label>
<input type="hidden" name="MAX_FILE_SIZE" value="2500000"> <input type="file" name="img2">


<label for="img3">Image 3:</label>
<input type="hidden" name="MAX_FILE_SIZE" value="2500000"> <input type="file" name="img3">


<label for="img4">Image 4:</label>
<input type="hidden" name="MAX_FILE_SIZE" value="2500000"> <input type="file" name="img4">


<label for="img5">Image 5:</label>
<input type="hidden" name="MAX_FILE_SIZE" value="2500000"> <input type="file" name="img5"><br />

 

 

Thanks in advance.

 

Link to comment
Share on other sites

I have changed that, Here is the new updated PHP

 

I can see the place holder for the images, but its like they are not going to the server.

 

<?php

    $email = $_POST ['email'];
    $quote = $_POST ['quote'];
    $item = $_POST ['item'];
    $inventory = $_POST ['inventory'];
    $category = $_POST ['category'];
    $manu = $_POST ['manu'];
    $model = $_POST ['model'];
    $condition = $_POST ['condition'];
    $dimension = $_POST ['dimension'];
    $desc = $_POST ['desc'];
    $skidprice = $_POST ['skidprice'];
    $unitprice = $_POST ['unitprice'];
    $totalprice = $_POST ['totalprice'];
    $img1 = $_FILES ['img1'];
    $img2 = $_FILES ['img2'];
    $img3 = $_FILES ['img3'];
    $img4 = $_FILES ['img4'];
    $img5 = $_FILES ['img5'];
    
    
    
    

    
function imgReisize($uploadedfile, $Destination, $Thumb){
//this is the function that will resize and copy our images

// Create an Image from it so we can do the resize
$src = imagecreatefromjpeg($uploadedfile);

// Capture the original size of the uploaded image
list($width,$height)=getimagesize($uploadedfile);

// For our purposes, I have resized the image to be
// 600 pixels wide, and maintain the original aspect
// ratio. This prevents the image from being "stretched"
// or "squashed". If you prefer some max width other than
// 600, simply change the $newwidth variable
$newwidth=600;
$newheight=($height/$width)*600;
$tmp=imagecreatetruecolor($newwidth,$newheight);

// this line actually does the image resizing, copying from the original
// image into the $tmp image
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);

// now write the resized image to disk. I have assumed that you want the
// resized, uploaded image file to reside in the ./images subdirectory.
$filename = $Destination;
imagejpeg($tmp,$filename,100);

// For our purposes, I have resized the image to be
// 150 pixels high, and maintain the original aspect
// ratio. This prevents the image from being "stretched"
// or "squashed". If you prefer some max height other than
// 150, simply change the $newheight variable
$newheight=150;
$newwidth=($width/$height)*150;
$tmp=imagecreatetruecolor($newwidth,$newheight);

// this line actually does the image resizing, copying from the original
// image into the $tmp image
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);

// now write the resized image to disk. I have assumed that you want the
// resized, uploaded image file to reside in the ./images subdirectory.
$filename = $Thumb;
imagejpeg($tmp,$filename,100);

imagedestroy($src);
imagedestroy($tmp); // NOTE: PHP will clean up the temp file it created when the request
// has completed.

echo "Successfully Uploaded: <img src='".$filename."'>";
}

    if(isset($_POST[submit])){
     $imgNumb=1; //This the "pointer" to images
     $DestinationDir="./images/";  //Place the destination dir here
     $ThumbDir="./images/thumbs/";  //Place the thumb dir here

       while($_FILES["img".$imgNumb][tmp_name]){
              $Unique=microtime(); // We want unique names, right?
              $destination=$DestinationDir.md5($Unique).".jpg";
              $thumb=$ThumbDir.md5($Unique).".jpg";
              imgReisize($_FILES["img".$imgNumb][tmp_name], $destination, $thumb);
              $imgNumb++;
       }
    }
    

    
    
    // Always set content-type when sending HTML email
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

    // More headers
    $headers .= 'From: All Food Equipment<sales[MENTION=93556]ALL[/MENTION]foodequip.com>' . "\r\n";

    $headers .= "Message-ID: <".$now." sales@".$_SERVER['SERVER_NAME'].">\r\n";
    $headers .= "X-Mailer: PHP v".phpversion()."\r\n";         

    $subject = "Your All Food Equip Quote";
    
    $msg = 
            "    
            <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">
<html>
<head><link href=\"http://www.allfoodequip.com/admin/quote/style.css\" rel=\"stylesheet\" type=\"text/css\"></head>
<body>
<div id=\"container\" style=\"width:960px;
    height:auto;
    margin:0 auto;
    border-right: 2px solid #666;
    border-left: 2px solid #666;\">
<div id=\"header\"       style=\"background-image:url([url=http://www.allfoodequip.com/admin/quote/images/banner_bg.jpg);]http://www.allfoodequip.com/admin/quote/images/banner_bg.jpg);[/url]
    width:100%;
    height:149px;\"></div>
<!--Closes header-->
<div id=\"subHead\" 
style=\"background-image:url([url=http://www.allfoodequip.com/admin/quote/images/menu_bg.jpg);]http://www.allfoodequip.com/admin/quote/images/menu_bg.jpg);[/url]
    width:100%;
    height:42px;\"></div>
<!--closes subHead-->
<div class=\"contents\" style=\"background:#f2f1f1;
    padding-right: 25px;
    padding-left: 25px;\">
  <h1 style=\"margin:0px;padding:10px 0 5px;font-size:18px;\">Your All Food Equipment Quote:</h1>
  <table width=\"700\" border=\"0\" class=\"table\" style=\"padding:0px 0px 15px;\">
<tr>
<td width=\"119\">Quote #:......................................................... </td>
      <td width=\"208\">$quote</td>
    </tr>
<tr>
<td>Item:..............................................................</td>
      <td>$item</td>
    </tr>
<tr>
<td>Inventory:.......................................................</td>
      <td>$inventory</td>
    </tr>
<tr>
<td>Category:.......................................................</td>
      <td>$category</td>
    </tr>
<tr>
<td>Manufacturer:.................................................</td>
      <td>$manu</td>
    </tr>
<tr>
<td>Model:...........................................................</td>
      <td>$model</td>
    </tr>
<tr>
<td>Condition:......................................................</td>
      <td>$condition</td>
    </tr>
<tr>
<td>Dimension:....................................................</td>
      <td>$dimension</td>
    </tr>
<tr>
<td>Description:...................................................</td>
      <td>$desc</td>
    </tr>
    <br>
<tr>
<td><b>Skid Price:</b>.................................................</td>
      <td><b>$skidprice</b></td>
    </tr>
<tr>
<td><b>Unit Price:</b>.................................................</td>
      <td><b>$unitprice</b></td>
    </tr>
<tr>
<td><b>Total Price:</b>................................................</td>
      <td><b>$totalprice</b></td>
    </tr>
</table>
<div class=\"t_middle\"> <img name=\"Img\" src=\"$img1\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"><img name=\"Img\" src=\"$img2\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"><img name=\"Img\" src=\"$img3\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"><img name=\"Img\" src=\"$img4\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"><img name=\"Img\" src=\"$img5\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\">
</div>
  <div class=\"break\" style=\"padding: 15px 0px;
    width:100%;\"><hr></div>
<!--break-->
  <!--close t_middle-->

  <div class=\"contactUs\">
    <p style=\"color:#650035;\">How to contact us:</p>
    <ul class=\"contact_list\" style=\"margin:0px;padding:0px;color:#650035;line-height:25px;padding-bottom:30px;list-style:none;\">
<li>Visit us Online: www.allfoodequip.com</li>
      <li>Contact: Dino Roberts</li>
      <li>Direct Line: 615-788-2953 </li>
      <li>Email: [email]dino[MENTION=93556]ALL[/MENTION]foodequip.com[/email]</li>
    </ul>
<ul class=\"contact_list\" style=\"margin:0px;padding:0px;color:#650035;line-height:25px;padding-bottom:30px;list-style:none;\">
<li>All Food Equipment</li>
      <li>1240 Industrial Park Road</li>
      <li>Columbia, TN 38401</li>
      <li>Main Office: 931-490-1977</li>
    </ul>
</div>
  <p style=\"font-size:14px;color:#333;\">TERMS & CONDITIONS: </p>
  
</div>
<!--close m_disc-->

<div id=\"footer\" style=\"clear: both;
    width: 100%;
    padding: 20px 0 20px 0;
    text-align: center;
    border-top: 1px solid #8b8a8b;
    background: #343233 url([url=http://www.allfoodequip.com/admin/quote/images/footer.jpg]http://www.allfoodequip.com/admin/quote/images/footer.jpg[/url]) no-repeat;\">
  <ul class=\"footer_list\" style=\"margin:0px;padding:0px;list-style:none;\">
<li style=\"padding: 0 10px;
    display: inline;
    border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com\" style=\"color: #cccccc;
    text-decoration: none;\">Home</a></li>
    <li style=\"padding: 0 10px;
    display: inline;
    border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com/new-equipment.php\" style=\"color: #cccccc;
    text-decoration: none;\">New Equipment</a></li>
    <li style=\"padding: 0 10px;
    display: inline;
    border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com/used-equipment.php\" style=\"color: #cccccc;
    text-decoration: none;\">Used Equipment</a></li>
    <li style=\"padding: 0 10px;
    display: inline;
    border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com/services.php\" style=\"color: #cccccc;
    text-decoration: none;\">Services</a></li>
    <li style=\"padding: 0 10px;
    display: inline;
    border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com/about-us.php\" style=\"color: #cccccc;
    text-decoration: none;\">About Us</a></li>
    <li class=\"last\" style=\"padding:0 10px;display:inline;border-right:none;\"><a href=\"http://www.allfoodequip.com/contact-us.php\" style=\"color: #cccccc;
    text-decoration: none;\">Contact Us</a></li>
  </ul>
<div class=\"margin_bottom_10\"></div><br>
  <span style=\"color:#FFF;\">Copyright © 2010 </span> - <a href=\"http://www.allfoodequip.com\"><font color=\"#FFFFCC\">All Food Equipment</font></a>
  <div class=\"margin_bottom_10\"></div>
  <!-- end of footer --> 

</div>
<!--container-->

</div>
</body>
</html>
";
            
    // MAIL SUBJECT
     $subject = "Your All Food Equip Quote";
    // TO MAIL ADDRESS
    $to="$email";
    
    

mail($to, $subject, $msg, $headers);




// Redirect
header("Location: Admin.php?Msg=Sent");

?>

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.