473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

email attachments

Hi

i wonder if any one can help. I have script that that sends a email
with mulitple attachments. It seems to work fine as i get the email
with the attachments on. But other people i send it to only get 1
attachment????

The script is below

<?php
// Read POST request params into global vars
$name = $_POST['your_name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$message = $_POST['message'];
$check1 = $_POST['check1'];
$check2 = $_POST['check2'];
$check3 = $_POST['check3'];
$check4 = $_POST['check4'];
$check5 = $_POST['check5'];
$color = $_POST['color'];
$manufacturer = $_POST['Manu'];
$findwebsite = $_POST['through'];
$comments = $_POST['comments'];

// Obtain file upload vars
$fileatt = $_FILES['pic1']['tmp_name'];
$fileatt_type = $_FILES['pic1']['type'];
$fileatt_name = $_FILES['pic1']['name'];

// Obtain file upload vars
$fileatt2 = $_FILES['pic2']['tmp_name'];
$fileatt2_type = $_FILES['pic2']['type'];
$fileatt2_name = $_FILES['pic2']['name'];

// Obtain file upload vars
$fileatt3 = $_FILES['pic3']['tmp_name'];
$fileatt3_type = $_FILES['pic3']['type'];
$fileatt3_name = $_FILES['pic3']['name'];

$headers = "From: Web@test";
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$message = "Name : " . $name . "\n";
$message .= "Phone : " . $phone . "\n";
$message .= "Email Address : " . $email . "\n";
$message .= "Item They Require : \n" ;
$message .= $check1 . "\n";

if ( $check2 <"" )
{
$message .= $check2 . "\n";

}

if ( $check3 <"")
{
$message .= $check3 . "\n";
}

if ( $check4 <"")
{
$message .= $check4 . "\n";

}

if ( $check5 <"")
{
$message .= $check5 . "\n";

}

$message .= "Color : " . $color . "\n";
$message .= "Manufacturer : " . $manufacturer . "\n";
$message .= "Found Web Through : " . $findwebsite . "\n";
$message .= "Comments \n" . $comments . "\n";

if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);

// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";

// Base64 encode the file data
$data = chunk_split(base64_encode($data));

// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";

}

if (is_uploaded_file($fileatt2)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt2,'rb');
$data = fread($file,filesize($fileatt2));
fclose($file);

// Add a multipart boundary above the plain message
// $message = "This is a multi-part message in MIME format.\n\n" .
// "--{$mime_boundary}\n" .
// "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
// "Content-Transfer-Encoding: 7bit\n\n" .
// $message . "\n\n";

// Base64 encode the file data
$data = chunk_split(base64_encode($data));

// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt2_type};\n" .
" name=\"{$fileatt2_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt2_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";

}

if (is_uploaded_file($fileatt3)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt3,'rb');
$data = fread($file,filesize($fileatt3));
fclose($file);

// Add a multipart boundary above the plain message
//$message = "This is a multi-part message in MIME format.\n\n" .
// "--{$mime_boundary}\n" .
// "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
// "Content-Transfer-Encoding: 7bit\n\n" .
// $message . "\n\n";

// Base64 encode the file data
$data = chunk_split(base64_encode($data));

// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt3_type};\n" .
" name=\"{$fileatt3_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt3_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}

// Send the message
$ok = @mail("<taken addrress out for protection>", "Web Enquiry",
$message, $headers);
if ($ok) {
echo "<span class='title'>The following details have been sent<br></
span>";
echo "<p><B>Name : </B>" . $name . "</p>";
echo "<p><B>Phone Number :</B" . $phone . "</p>";
echo "<p><B>Email Address :</B" . $email . "</p>";
echo "<br><B>Item Required :</B";
echo "<br>" . $check1;

if ( $check2 <"" )
{
echo "<BR>" . $check2;
}

if ( $check3 <"")
{
echo "<BR>" . $check3;
}
if ( $check4 <"")
{
echo "<BR>" . $check4;
}

if ( $check5 <"")
{
echo "<BR>" . $check5;
}
echo "<p><B>Color :</B" . $color . "</p>";
echo "<p><B>Manufacturer :</B" . $manufacturer . "</p>";
echo "<p><B>Found Site Through :</B" . $findwebsite . "</p>";
echo "<p><B>Comments :</B" . $comments . "</p>";

} else {

echo "<p>Mail could not be sent. Sorry!</p>";
}

?>
Aug 22 '08 #1
0 1261

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Paul Schmidt | last post by:
Dear list: I am new to python, and I am trying to figure out the short answer on something. I want to open a POP3 mailbox, read the enclosed mail using the POP3 module, , and then process it...
3
by: LutherRevisited | last post by:
Is there a way I can put a message together without having to download any attachments there may be at the same time. I'm not having any problems dealing with attachments, but the way I'm doing...
5
by: morphex | last post by:
Hi, I have an email that's in the utf-8 encoding, and I'm getting this error message when I try to send it using smtplib: * Module smtplib, line 688, in sendmail * Module smtplib, line 485,...
5
by: paii, Ron | last post by:
How do I setup a email with attachment for preview but require the user to push the SEND button in Outlook. I have the following function but it sends the email without the sender ever seeing it. ...
4
by: Russell Bungay | last post by:
Hello all, I have written a short function, based on a recipe in the Python Cookbook, that sends an e-mail. The function takes arguments that define who the e-mail is to, from, the subject, the...
1
by: mike11d11 | last post by:
If someone could help me, I need to be able to send attachments from my access database that I have created. This database runs queries then generates a report off the queries from underlying...
10
by: OdAwG | last post by:
Hello All, Is it possible to send an email from Access? I found a Microsoft article on how to do this but I keep getting an error "RUNTIME ERROR 438" -- Object doesn't support this property or...
10
by: Walshi | last post by:
Hi all, I'm a relative newby to access and VBA etc. My forms and tables etc are working great and saving lots of time...However... I have two databases with the exact same table format. I want...
2
by: oyster | last post by:
I find that the existing email moudle is some hard for me to understand, especially the part of how to set the CC, BCC and attach the files. Is there any more easy one like this p-code? import...
1
by: budyerr | last post by:
All, I am trying to build a email submission form using asp.net. I currently have a web form page that will upload to my webhosting server, attach to email then delete the file after sending. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.