Hi Guys,
This is strange. I've got it working now so it sends anything under 1mb with an attachment.
But it it's over 1mb there is no attachment and there is nothing with the email - even though it takes ages to go when you press the send button?
Any ideas thanks?
HTML Code:
<html>
<head>
<title>Send us your design brief</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="main.css">
</head>
<body bgcolor="#FFFFFF">
<form action="mail.php" method="POST" enctype="multipart/form-data">
<table width="80%" border="0" align="center" class="dotted" height="677">
<tr>
<td>
<p> </p>
<table width="94%" cellspacing="0" cellpadding="0" align="center">
<tr>
<th colspan="5" background="images/top.jpg">
<div align="left"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b><img src="images/design_3.jpg" width="717" height="46">
</b></font></div>
</th>
</tr>
<tr valign="top">
<td rowspan="4" width="26%">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td class="maintext"><img src="images/1.gif" width="114" height="24"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>
</b></font></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="3"><b>1a.
Your Name:</b></font></td>
</tr>
<tr>
<td>
<input type="text" name="your_name" class="box" size="20" value="" />
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="3"><b>1b.
Centre (ie Paisley etc)</b></font></td>
</tr>
<tr>
<td>
<input type="text" name="your_centre" class="box" size="20" value="" />
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="3"><b>1c.
Your Telephone</b></font></td>
</tr>
<tr>
<td>
<input type="text" name="your_telephone" class="box" size="20" value="" />
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><font size="3"><b><font face="Arial, Helvetica, sans-serif">1d.
Your Email</font></b></font></td>
</tr>
<tr>
<td>
<input type="text" name="from" class="box" size="20" value="" />
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><img src="images/2.gif" width="176" height="24"></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="3"><b>2a.
Client name:</b></font></td>
</tr>
<tr>
<td>
<input type="text" name="client_name" class="box" size="20" value="" />
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="3"><b>2b.
Client history</b></font></td>
</tr>
<tr>
<td>
<table width="80%" border="0" cellspacing="0" cellpadding="0" class="box">
<tr>
<td colspan="2" valign="top" height="22">
<input type="radio" name="client" value="Current Client">
Current Client <br>
<input type="radio" name="client" value="New Client">
New Client <br>
<input type="radio" name="client" value="Prospective Client">
Prospective Client</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td rowspan="4" width="1%"><img src="blank.gif" width="15" height="30"></td>
<td rowspan="4" width="32%">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td class="maintext"><img src="images/3.gif" width="186" height="24"></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="3"><b>3a.
Sizes required</b></font></td>
</tr>
<tr>
<td>
<input type="text" name="sizes_required" class="box" size="20" value="" />
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="3"><b>3b.
Proof required by</b></font></td>
</tr>
<tr>
<td>
<input type="text" name="proof_required_by" class="box" size="20" value="" />
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="3"><b>3c.
Colour specification</b></font></td>
</tr>
<tr>
<td height="60">
<table width="80%" border="0" cellspacing="0" cellpadding="0" class="box">
<tr>
<td colspan="2">
<div align="left">
<input type="radio" name="colour" value="Mono">
Mono</div>
<div align="left">
<input type="radio" name="colour" value="Spot Colour">
Spot Colour</div>
<div align="left">
<input type="radio" name="colour" value="Full Colour">
Full Colour</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="6"> </td>
</tr>
<tr>
<td>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="3"><b><font face="Arial, Helvetica, sans-serif">3d.
Please attach any documents:</font></b></font> </p>
<p>
<input type="file" name="fileatt" />
<input type="file" name="fileatt2" />
<input type="file" name="fileatt3" />
</p>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td height="27"><font face="Verdana, Arial, Helvetica, sans-serif" size="3"><b><font face="Arial, Helvetica, sans-serif">3e.
I have attached the following:</font></b></font></td>
</tr>
<tr valign="top">
<td height="176">
<table width="80%" border="0" cellspacing="0" cellpadding="0" class="box">
<tr>
<td width="10%" valign="top">
<input type="checkbox" name="artwork_and_logos_attached" value="Yes" />
</td>
<td width="90%" class="small_text">
<div align="left">Artwork/Logos</div>
</td>
</tr>
<tr>
<td width="10%" valign="top">
<input type="checkbox" name="previous_ad_attached" value="Yes" />
</td>
<td width="90%" class="small_text">
<div align="left">Previous Ad</div>
</td>
</tr>
<tr>
<td width="10%" valign="top">
<input type="checkbox" name="rough_outline_attached" value="Yes" />
</td>
<td width="90%" class="small_text">
<div align="left">Rough Outline</div>
</td>
</tr>
<tr>
<td width="10%" valign="top">
<input type="checkbox" name="hard_copy_reference_attached" value="Yes" />
</td>
<td width="90%" class="small_text">Hard Copy Reference</td>
</tr>
<tr>
<td width="10%" valign="top" height="8">
<input type="checkbox" name="other_attached" value="Yes">
</td>
<td width="90%" class="small_text" height="8">Other -
Please include details </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td rowspan="4" width="1%"><img src="blank.gif" width="15" height="30"></td>
<td rowspan="4" width="40%">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr valign="top">
<td class="maintext" height="2"><img src="images/4.gif" width="138" height="24"></td>
</tr>
<tr valign="top">
<td height="2"><font face="Arial, Helvetica, sans-serif" size="3"><b>Please
specify any other information you think may be useful to the
designer e.g. company colours (Pantone colours etc.), imagery,
service company provides, brief history of relationship with
us, client website address etc.</b></font></td>
</tr>
<tr valign="top">
<td class="maintext" height="408">
<div align="center">
<textarea name="other_details" class="box" cols="32" rows="19" /></textarea>
<br>
<br>
<input type="submit" name="Submit" value="Submit form" class="buttons">
<input type="reset" name="Submit2" value="Reset form" class="buttons">
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top"></tr>
<tr valign="top"></tr>
<tr> </tr>
</table>
<br>
<table width="72%" cellspacing="0" cellpadding="0" align="center">
</table>
<table width="94%" border="0" cellspacing="1" cellpadding="1" align="center" background="images/bottom_bit.jpg">
<tr>
<td>
<div align="left"><img src="images/bottom.jpg" width="285" height="48" border="0"></div>
</td>
</tr>
</table>
<br>
</td>
</tr>
</table>
<p> </p>
</form>
<font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b> </b></font>
</body>
</html>
php mail code:
PHP Code:
<html>
<head>
<title> Sending Email </title>
</head>
<body>
<?php
// Read POST request params into global vars
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$to="me@me.co.uk";
$subject="Design Request form";
$your_name = $_POST['your_name'];
$your_centre = $_POST['your_centre'];
$your_telephone = $_POST['your_telephone'];
$client_name = $_POST['client_name'];
$client = $_POST['client'];
$sizes_required = $_POST['sizes_required'];
$proof_required_by = $_POST['proof_required_by'];
$colour = $_POST['colour'];
$artwork_and_logos_attached = $_POST['artwork_and_logos_attached'];
$previous_ad_attached = $_POST['previous_ad_attached'];
$rough_outline_attached = $_POST['rough_outline_attached'];
$hard_copy_reference_attached = $_POST['hard_copy_reference_attached'];
$other_attached = $_POST['other_attached'];
$other_details = $_POST['other_details'];
if (!empty($your_name)) {
$message .= 'Your Name: '. $your_name ."\n\n";
}
if (!empty($your_centre)) {
$message .= 'Your Centre: '. $your_centre ."\n\n";
}
if (!empty($your_telephone)) {
$message .= 'Your Telephone: '. $your_telephone ."\n\n";
}
if (!empty($client_name)) {
$message .= 'Client Name: '. $client_name ."\n\n";
}
if (!empty($client)) {
$message .= 'Client Type: '. $client ."\n\n";
}
if (!empty($sizes_required)) {
$message .= 'Sizes Required: '. $sizes_required ."\n\n";
}
if (!empty($proof_required_by)) {
$message .= 'Proof Required by: '. $proof_required_by ."\n\n";
}
if (!empty($colour)) {
$message .= 'Advert Colour: '. $colour ."\n\n";
}
if (!empty($artwork_and_logos_attached)) {
$message .= 'Artwork or Logos attached: '. $artwork_and_logos_attached ."\n\n";
}
if (!empty($previous_ad_attached)) {
$message .= 'Previous Ad Attached: '. $previous_ad_attached ."\n\n";
}
if (!empty($rough_outline_attached)) {
$message .= 'Rough Outline Attached: '. $rough_outline_attached ."\n\n";
}
if (!empty($hard_copy_reference_attached)) {
$message .= 'Hard Copy Reference Attached: '. $hard_copy_reference_attached ."\n\n";
}
if (!empty($other_attached)) {
$message .= 'Other Attached: '. $other_attached ."\n\n";
}
if (!empty($other_details)) {
$message .= 'Other details: '. $other_details ."\n\n";
}
// Obtain file upload vars
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
$fileatt2 = $_FILES['fileatt2']['tmp_name'];
$fileatt_type2 = $_FILES['fileatt2']['type'];
$fileatt_name2 = $_FILES['fileatt2']['name'];
$fileatt3 = $_FILES['fileatt3']['tmp_name'];
$fileatt_type3 = $_FILES['fileatt3']['type'];
$fileatt_name3 = $_FILES['fileatt3']['name'];
$headers = "From: $from";
if (is_uploaded_file($fileatt) || is_uploaded_file($fileatt2) || is_uploaded_file($fileatt3)) {
// Read the file to be attached ('rb' = read binary)
if (is_uploaded_file($fileatt)) {
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
}
if (is_uploaded_file($fileatt2)) {
$file2 = fopen($fileatt2,'rb');
$data2 = fread($file2,filesize($fileatt2));
fclose($file2);
// Base64 encode the file data
$data2 = chunk_split(base64_encode($data2));
}
if (is_uploaded_file($fileatt3)) {
$file3 = fopen($fileatt3,'rb');
$data3 = fread($file3,filesize($fileatt3));
fclose($file3);
// Base64 encode the file data
$data3 = chunk_split(base64_encode($data3));
}
// 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}\"";
// 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;\n charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n" .
"--{$mime_boundary}\n";
// Add file attachment(s) to the message
if ($fileatt_name > "") {
$message .= "Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n\n" .
$data . "\n" .
"--{$mime_boundary}\n";
}
if ($fileatt_name2 > "") {
$message .= "Content-Type: {$fileatt_type2};\n" .
" name=\"{$fileatt_name2}\"\n" .
"Content-Transfer-Encoding: base64\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name2}\"\n\n" .
$data2 . "\n" .
"--{$mime_boundary}\n";
}
if ($fileatt_name3 > "") {
$message .= "Content-Type: {$fileatt_type3};\n" .
" name=\"{$fileatt_name3}\"\n" .
"Content-Transfer-Encoding: base64\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name3}\"\n\n" .
$data3 . "\n" .
"--{$mime_boundary}";
}
$message .= "--\n\n";
}
// Send the message
$ok = @mail($to, $subject, $message, $headers);
if ($ok) {
echo "<p>Thank you. An email has been sent to our Design Team who will be in touch with you shortly.</p>";
} else {
echo "<p>Mail could not be sent. Sorry!</p>";
}
?>
</body>
</html>
Thanks
Bookmarks