![]() |
|
|||||||
| Register | FAQ | Members List | Arcade | Dev Directory | HB Bank | Calendar | Search | Today's Posts | Mark Forums Read |
| PHP, ASP, JavaScript, Etc. / Programmers: For people looking for a PHP programmer. |
| Have A Look At Some Of Our Webmaster Related Sponsors! | |||||
![]() Script Directory |
![]() Advertise Here |
![]() Market Leverage |
![]() Free Templates |
![]() 3D Guide-characters |
![]() Advertise Here |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Junior Member
|
Code:
<?php
//mail formulier voor bijlage
$email ='my@email.com';
//geneer boundary
DEFINE('bound',md5(uniqid(time())));
//check request method
if($_SERVER['REQUEST_METHOD'] ==
'POST')
{
//if file upload send with email as mixed
if(!empty($_FILES['file']['name']))
{
//check filesize
if($_FILES['file']['size'] < 1024*50)
{
$headers = "From: ".$_POST['from']
." <".$_POST['email'].">\r\n";
$headers .= "Reply-To: ".$_POST
['from']." <".$_POST['email'].">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
//email exist out of more parts, some
thing (can't say it in english) show's php it's multipart
$headers .= "Content-Type: multipart/
mixed; boundary=\"".bound."\"\r\n";
//we send the attachment
$headers .= "Content-Disposition:
attachment\r\n";
//readfile
$fp = fopen($_FILES['file']
['tmp_name'],'r');
$bestand = fread($fp,$_FILES['file']
['size']);
fclose($fp);
//create body
//generating a body. Dit is some multi
part bull****
$body.= "This is a multi-part message
in MIME format.\r\n";
$body.= "\r\n";
//boundary
$body.= "--".bound."\r\n";
//content type + charater set (iso in this
case)
$body.= "Content-Type: text/plain;
charset=iso-8859-1\r\n";
//coding (7 bit)
$body.= "Content-Transfer-Encoding:
7bit\r\n";
$body.= "\r\n";
//the message
$body.= $_POST['bericht'] ."\r\n";
//boundary
$body.= "--".bound."\r\n";
//content typ + name file (database.sql)
$body .= "Content-Type: application/
octet-stream; name=".$_FILES['file']['name']."\r\n";
//coding
$body .= "Content-Transfer-Encoding:
base64\r\n";
//add the attachment
$body.= "Content-disposition:
attachment\r\n";
$body .= "\n";
//the content of the file
$body .= chunk_split(base64_encode($
bestand )) . "\r\n";
mail($email,$_POST['subject'],$body,$
headers);
echo 'Email (With attachment) is send';
}
else
{
echo 'File is too large';
}
}
else
{
$headers = "From: ".$_POST['from']."
<".$_POST['email'].">\r\n";
$headers .= "Reply-To: ".$_POST
['from']." <".$_POST['email'].">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$bericht = $_POST['bericht'];
mail($email,$_POST['subject'],$bericht,$
headers);
echo 'Email (Without attachement) is
send';
}
}
else
{
//mailform
echo "<form action=\"" . $_SERVER
['PHP_SELF'] . "\" method=\"POST\"
enctype=\"multipart/form-data\">";
echo "Name: <input type='text'
name='from'><br>";
echo "Email:<input type='text'
name='email'><br>";
echo "Subject:<input type='text'
name='subject'><br>";
echo "File:<input type='file'
name='file'><br>";
echo "Message:<textarea name='bericht'></
textarea><br />";
echo "<input type=\"submit\"
value=\"Send\">";
}
?>
you will have to change my@email.com in your real email adress I sugest you don't change anything else exept if you know what you are doing |
|
|
|
|
|
#2 (permalink) |
|
Member
|
This is a very unsafe script because it is possible for anyone to abuse it to spam people. There is an article here that describes how to secure your script:
http://www.securephpwiki.com/index.php/Email_Injection |
|
|
|
|
|
#3 (permalink) | |
|
Field Master
|
Quote:
|
|
|
|
|
|
|
#4 (permalink) |
|
Field Master
|
YEs very interesting..
I am trying to use this script.. well Good work.. When this work is completed i will submit her ethe link.. Okay Bye bye
__________________
Always be Happy... ![]() |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|