Click to See Complete Forum and Search --> : emailing form results - attachments
matt00
11-27-2006, 04:51 AM
I am using the mailer.php to email results from a form, but it doesnt email the attachments for people to attatch files, can it be changed or somthing added to the code so that it can email the atatchments or is there a simple code similar to the mailer.php that I can use?
I dont know much about editing php like what to change...i have tried heaps of them but i dont know if i am changing the right fields to get it to work...if someone could help me out here it would be great.
matt
so_is_this
11-27-2006, 11:19 AM
If the mailer object itself doesn't supply a method for creating attachments, then the only other choice is to provide MIME-encoded, multi-part content for the body of the message.
http://www.zend.com/zend/spotlight/sendmimeemailpart1.php?article=sendmimeemailpart1&kind=sl&id=5626&open=1&anc=0&view=1
matt00
11-27-2006, 05:34 PM
well that kinda made me a bit more confussed........
does anyone have a file or code or whaterver that all i have to do is change the email address and link the webpage to the file and it will work with attachments??
so_is_this
11-27-2006, 06:48 PM
All you had to do was to follow through on that article and they would give you the class file and examples, too. HINT: Go to the code author's website to download the zip file with examples.
matt00
11-27-2006, 06:53 PM
sorry didnt mean to sound rude......
I downloaded the files and looked at the example one but it had the form saved as a php not htm.....should my form be saved as a php then?
thanx for your help by the way
so_is_this
11-27-2006, 07:01 PM
Yes, there are two schools of thought on form processing. One uses an HTML FORM page and submits to a PHP page for processing. The other uses a PHP FORM page which submits to itself for processing and then redirects to a "success" page on completion. I hold to the latter. ;)
matt00
11-27-2006, 08:32 PM
well i got it to sort of work....but still problems.....
my form has all address details and other information but when the submit button is clicked all that information doesnt come through in the email.......
am i doing something wrong....
what i did was i got the example page from the zip file and copied the relevant php code and pasted it in the same position in my form page and changed the email address. I also copied over the other files it needs into the same directory.......but somthing isnt right.......how can you help?
so_is_this
11-27-2006, 08:41 PM
Post your code.
matt00
11-27-2006, 08:55 PM
this is the form without the php scrip added:
<table width="55%" height="555" border="0" align="center">
<tr>
<td height="137" colspan="4"> <div align="center"><img src="files/topbar1.gif" name="image1" width="795" height="133" border="0" align="absmiddle" usemap="#Map" id="image1"></div></td>
</tr>
<tr>
<td width="24%" height="153"> </td>
<td height="75" colspan="2" class="text">
<form action="application1.htm" method="post" enctype="multipart/form-data" name="form1">
<p> </p>
<p> </p>
<table width="94%">
<tr>
<td class="text">Surname</td>
<td height="38" class="text"> <p>
<input name="Surname2" size="15" type="text">
</p></td>
<td class="text">Given</td>
<td height="38" class="text"> <input name="Given2" size="15" type="text"></td>
</tr>
<tr>
<td class="text">D.O.B.</td>
<td height="40" class="text"> <input name="DOB2" type="text" id="DOB4" size="15"></td>
<td height="40" class="text">Sex</td>
<td height="40" class="text"> <select size="1" name="select">
<option selected="selected">Male</option>
<option>Female</option>
</select></td>
</tr>
<tr>
<td class="text">Address</td>
<td height="40" class="text"> <input name="address2" size="25" type="text"></td>
<td height="40" class="text">Suburb</td>
<td height="40" class="text"> <input name="Suburb2" type="text" id="Suburb3" size="15"></td>
</tr>
<tr>
<td class="text">Postcode</td>
<td height="35" class="text"> <input name="pc2" type="text" id="pc" size="15"></td>
<td height="35" class="text">State</td>
<td height="35" class="text"> <select size="1" name="select">
<option selected>SA</option>
<option>NT</option>
<option>NSW</option>
<option>QLD</option>
<option>TAS</option>
<option>VIC</option>
<option>WA</option>
</select></td>
</tr>
<tr>
<td class="text">Country </td>
<td height="37" class="text"> <input name="Country2" size="15" value="Australia" type="text"></td>
<td height="37" class="text">Resident </td>
<td height="37" class="text"> <select size="1" name="select">
<option selected="selected">Yes</option>
<option>No</option>
</select></td>
</tr>
<tr>
<td class="text">Phone(H) </td>
<td height="35" class="text"> <p>
<input name="Phoneh2" size="15" type="text">
</p></td>
<td height="35" class="text">Phone(M)</td>
<td height="35" class="text"> <input name="Phonem2" size="15" type="text"></td>
</tr>
<tr>
<td class="text"><p>Nationality </p></td>
<td height="34" class="text"> <input name="nationality" type="text" id="nationality" size="15"></td>
<td height="34" class="text">Tax File #</td>
<td height="34" class="text"> <input name="tfn2" size="15" type="text"></td>
</tr>
<tr>
<td class="text">Height</td>
<td height="-2" class="text"><input name="height2" size="5" type="text">
cm </td>
<td height="-2" class="text">Police record</td>
<td height="-2" class="text"><select size="1" name="select">
<option>Yes</option>
<option selected="selected">No</option>
</select></td>
</tr>
<tr>
<td class="text">Visa Required</td>
<td height="-2" class="text"><select size="1" name="select">
<option>Yes</option>
<option selected="selected">No</option>
</select></td>
<td height="-2" class="text">Transport</td>
<td height="-2" class="text"><select size="1" name="select">
<option selected="selected">Yes</option>
<option>No</option>
</select></td>
</tr>
<tr>
<td class="text">Visa #</td>
<td height="-2" class="text"><input name="visanum2" size="15" type="text"></td>
<td height="-2" class="text">Exp. Date</td>
<td height="-2" class="text"><input name="visaexpire2" size="15" type="text"></td>
</tr>
<tr>
<td class="text">Job Seeker ID</td>
<td height="-2" class="text"><input name="jsid2" size="15" type="text"></td>
<td height="-2" class="text">Position Type</td>
<td height="-2" class="text"><input name="position2" size="15" type="text"></td>
</tr>
<tr>
<td class="text">Email</td>
<td height="36" colspan="3" class="text"> <input name="email2" size="35" type="text"></td>
</tr>
<tr>
<td class="text"> <div align="left">
<p>Resume (C.V.)</p>
</div></td>
<td height="34" colspan="3" class="text"><b><font color="#993300" size="2">
<input name="resume" type="file" id="resume" >
</font></b></td>
</tr>
<tr>
<td class="text"><p>Comments</p>
<p> </p>
<p> </p></td>
<td height="-2" colspan="3" class="text"><b><font color="#993300" size="2">
<textarea rows="4" name="textarea" cols="40"></textarea>
</font></b></td>
</tr>
<tr>
<td class="text"> </td>
<td height="30" colspan="3" class="text"> <div align="right">
<input name="Submit2" type="submit" value="Submit">
</div></td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
</table>
<p> </p>
</form>
<p align="center"><br>
</p>
</td>
<td width="23%" height="75"><p align="center" class="text"> </p></td>
</tr>
<tr>
<td height="24" colspan="4"><div align="center"><font color="#999999" size="-7" face="Century Gothic">copyright
montica 2006</font></div></td>
</tr>
</table>
matt00
11-27-2006, 08:57 PM
this is the form with the php script pasted in:
<table width="55%" height="555" border="0" align="center">
<tr>
<td height="137" colspan="4"> <div align="center"><img src="files/topbar1.gif" name="image1" width="795" height="133" border="0" align="absmiddle" usemap="#Map" id="image1"></div></td>
</tr>
<tr>
<td width="24%" height="153"> </td>
<td height="75" colspan="2" class="text">
<?php
/* --------------------------------------------------
This example shows how to use the class to get an
attachment from a user and send it via email.
e.g., a job site where a prospect is sending
resume.
-------------------------------------------------- */
include "MIME.class";
define('TO', 'btstudio@internode.on.net'); # CHANGE THIS TO A REAL ADDRESS (yours?)
// Has there been a form submission? If yes, go on and
// process...
if (is_array($HTTP_POST_VARS)) {
if ($resume != 'none') {
$fname = './'.$resume_name; // make a real filename
// Get the content-type of the uploaded file
if (preg_match("!/x\-.+!i", $resume_type))
$type = OCTET;
else
$type = $resume_type;
$from = sprintf("'%s' <%s>", $name, $email) ;
copy($resume, $fname); //do error checking if need
$mime = new MIME_mail($from, TO, 'Resume', "Please find attached my resume", "Cc: $email");
$mime->fattach($fname, "Resume of $name", $type);
$mime->send_mail();
echo "Dear $name<p>Your resume has been emailed and a copy sent to you<br>";
unlink($resume); // remove the uploaded file
} else {
echo "Dear $name<p>You have not submitted your resume. Please use the browse button to attach it and click send!<br>";
}
}
?>
<form action="<?php echo $PHP_SELF;?>" method="post" enctype="multipart/form-data" name="form1">
<p> </p>
<p> </p>
<table width="94%">
<tr>
<td class="text">Surname</td>
<td height="38" class="text"> <p>
<input name="Surname2" size="15" type="text">
</p></td>
<td class="text">Given</td>
<td height="38" class="text"> <input name="Given2" size="15" type="text"></td>
</tr>
<tr>
<td class="text">D.O.B.</td>
<td height="40" class="text"> <input name="DOB2" type="text" id="DOB4" size="15"></td>
<td height="40" class="text">Sex</td>
<td height="40" class="text"> <select size="1" name="select">
<option selected="selected">Male</option>
<option>Female</option>
</select></td>
</tr>
<tr>
<td class="text">Address</td>
<td height="40" class="text"> <input name="address2" size="25" type="text"></td>
<td height="40" class="text">Suburb</td>
<td height="40" class="text"> <input name="Suburb2" type="text" id="Suburb3" size="15"></td>
</tr>
<tr>
<td class="text">Postcode</td>
<td height="35" class="text"> <input name="pc2" type="text" id="pc" size="15"></td>
<td height="35" class="text">State</td>
<td height="35" class="text"> <select size="1" name="select">
<option selected>SA</option>
<option>NT</option>
<option>NSW</option>
<option>QLD</option>
<option>TAS</option>
<option>VIC</option>
<option>WA</option>
</select></td>
</tr>
<tr>
<td class="text">Country </td>
<td height="37" class="text"> <input name="Country2" size="15" value="Australia" type="text"></td>
<td height="37" class="text">Resident </td>
<td height="37" class="text"> <select size="1" name="select">
<option selected="selected">Yes</option>
<option>No</option>
</select></td>
</tr>
<tr>
<td class="text">Phone(H) </td>
<td height="35" class="text"> <p>
<input name="Phoneh2" size="15" type="text">
</p></td>
<td height="35" class="text">Phone(M)</td>
<td height="35" class="text"> <input name="Phonem2" size="15" type="text"></td>
</tr>
<tr>
<td class="text"><p>Nationality </p></td>
<td height="34" class="text"> <input name="nationality" type="text" id="nationality" size="15"></td>
<td height="34" class="text">Tax File #</td>
<td height="34" class="text"> <input name="tfn2" size="15" type="text"></td>
</tr>
<tr>
<td class="text">Height</td>
<td height="-2" class="text"><input name="height2" size="5" type="text">
cm </td>
<td height="-2" class="text">Police record</td>
<td height="-2" class="text"><select size="1" name="select">
<option>Yes</option>
<option selected="selected">No</option>
</select></td>
</tr>
<tr>
<td class="text">Visa Required</td>
<td height="-2" class="text"><select size="1" name="select">
<option>Yes</option>
<option selected="selected">No</option>
</select></td>
<td height="-2" class="text">Transport</td>
<td height="-2" class="text"><select size="1" name="select">
<option selected="selected">Yes</option>
<option>No</option>
</select></td>
</tr>
<tr>
<td class="text">Visa #</td>
<td height="-2" class="text"><input name="visanum2" size="15" type="text"></td>
<td height="-2" class="text">Exp. Date</td>
<td height="-2" class="text"><input name="visaexpire2" size="15" type="text"></td>
</tr>
<tr>
<td class="text">Job Seeker ID</td>
<td height="-2" class="text"><input name="jsid2" size="15" type="text"></td>
<td height="-2" class="text">Position Type</td>
<td height="-2" class="text"><input name="position2" size="15" type="text"></td>
</tr>
<tr>
<td class="text">Email</td>
<td height="36" colspan="3" class="text"> <input name="email2" size="35" type="text"></td>
</tr>
<tr>
<td class="text"> <div align="left">
<p>Resume (C.V.)</p>
</div></td>
<td height="34" colspan="3" class="text"><b><font color="#993300" size="2">
<input name="resume" type="file" id="resume" >
</font></b></td>
</tr>
<tr>
<td class="text"><p>Comments</p>
<p> </p>
<p> </p></td>
<td height="-2" colspan="3" class="text"><b><font color="#993300" size="2">
<textarea rows="4" name="textarea" cols="40"></textarea>
</font></b></td>
</tr>
<tr>
<td class="text"> </td>
<td height="30" colspan="3" class="text"> <div align="right">
<input name="Submit2" type="submit" value="Submit">
</div></td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
</table>
<p> </p>
</form>
<p align="center"><br>
</p>
</td>
<td width="23%" height="75"><p align="center" class="text"> </p></td>
</tr>
<tr>
<td height="24" colspan="4"><div align="center"><font color="#999999" size="-7" face="Century Gothic">copyright
montica 2006</font></div></td>
</tr>
</table>