/    Sign up×
Community /Pin to ProfileBookmark

emailing form results – attachments

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

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@so_is_thisNov 27.2006 — 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
Copy linkTweet thisAlerts:
@matt00authorNov 27.2006 — 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??
Copy linkTweet thisAlerts:
@so_is_thisNov 28.2006 — 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.
Copy linkTweet thisAlerts:
@matt00authorNov 28.2006 — 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
Copy linkTweet thisAlerts:
@so_is_thisNov 28.2006 — 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. ?
Copy linkTweet thisAlerts:
@matt00authorNov 28.2006 — 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?
Copy linkTweet thisAlerts:
@so_is_thisNov 28.2006 — Post your code.
Copy linkTweet thisAlerts:
@matt00authorNov 28.2006 — this is the form without the php scrip added:

[CODE]
<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">&nbsp;</td>
<td height="75" colspan="2" class="text">
<form action="application1.htm" method="post" enctype="multipart/form-data" name="form1">
<p>&nbsp;</p>
<p>&nbsp;</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>&nbsp;</p>
<p>&nbsp;</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">&nbsp;</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">&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
</form>
<p align="center"><br>
</p>
</td>
<td width="23%" height="75"><p align="center" class="text">&nbsp;</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>
[/CODE]
Copy linkTweet thisAlerts:
@matt00authorNov 28.2006 — this is the form with the php script pasted in:


[CODE]
<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">&nbsp;</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', '[email protected]'); # 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>&nbsp;</p>
<p>&nbsp;</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>&nbsp;</p>
<p>&nbsp;</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">&nbsp;</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">&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
</form>
<p align="center"><br>
</p>
</td>
<td width="23%" height="75"><p align="center" class="text">&nbsp;</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>
[/CODE]
×

Success!

Help @matt00 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...