I have a added a form to my site that sends its contents to my email, I want to add an extra part on the form where the user can add a MS Word document, and then this document be included on the email that is sent to me.
Is this possible with PHP, and if so, does anyone know of a tutorial I can look at?
Thanks
sending files in an email with php
Moderator: General Moderators
- cooper3000
- Forum Newbie
- Posts: 8
- Joined: Wed Jan 18, 2006 5:16 am
- Location: London
- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
Feyd is invariably correct
However, if you do not know how to work with the libaries yet, here is a mailing script i wrote for my website.
Code: Select all
<?php
#put conditions for $_POST, $_GET here
if ($_POST['ms_doc']) {
$msg = "E-MAIL SENT FROM YOUR WEBSITE\r\n";
$msg .= "Sender's NAME: \t{$_POST['name']}\r\n";
$msg .= "Sender's EMAIL:\t{$_POST['sender_email']}\r\n";
$msg .= stripslashes("ms_doc:\t{$_POST['ms_doc']}\r\n");
$to = "you@localhost.com\r\n";
$subject = "MS_DOC\r\n";
$mailtoheaders = "From: You <you@localhost.com>\r\n";
$mailheaders .= "Reply-To: {$_POST['sender_email']}\r\n";
mail($to, $subject, $msg, $mailheaders);
## put extra conditions here, like post the rest of the info to sample DB, or
## sample file
} else {
## put extra conditions here, like post the rest of the info to sample DB, or
## sample file
?>Akimm... have you heard of Email header injection? Your script is VERY insecure. I'd read up on that stuff.
Cooper... I'd just go with one of those libraries... swift is extremely easy to get support for since the creator is a regular poster here. Both of the libraries are pretty easy to work with anyway... so I'd just use one of those. You will also want to read up on email header injection if you aren't aware of it already.
Cooper... I'd just go with one of those libraries... swift is extremely easy to get support for since the creator is a regular poster here. Both of the libraries are pretty easy to work with anyway... so I'd just use one of those. You will also want to read up on email header injection if you aren't aware of it already.
- cooper3000
- Forum Newbie
- Posts: 8
- Joined: Wed Jan 18, 2006 5:16 am
- Location: London
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
which, by the way, is fantastic my good man... but he still needs to read up on it.d11wtq wrote:*cough* Swift deals with this for you. In fact, perhaps a little strongly though it wouldn't block anything it would just encode over the top of it.The Ninja Space Goat wrote:You will also want to read up on email header injection if you aren't aware of it already.