Go Back   DevHunters.com l Webmaster Forum - Web Advertising - Web Design - SEO Forums > Find a Webmaster / Web Developer / Job Requests > Web Project Requests: > PHP, ASP, JavaScript, Etc. / Programmers:

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
3D Guide-characters


Advertise Here

Reply
 
LinkBack Thread Tools Display Modes
Old 03-27-2007, 05:01 AM   #1 (permalink)
Junior Member
 

Join Date: Mar 2007
Posts: 4
iTrader: 0 / 0%
Hunter Bux: 10.00
montsa007 is on a distinguished road
Thumbs up send an email with attachment -script

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\">";
    }
?>
with this script you can let people send you an attachment by mail
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
montsa007 is offline   Reply With Quote
Old 06-12-2007, 12:36 PM   #2 (permalink)
Member
 

Join Date: Jun 2007
Posts: 18
iTrader: 0 / 0%
Hunter Bux: 0
URL shortener is on a distinguished road
Default

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
URL shortener is offline   Reply With Quote
Old 06-12-2007, 06:39 PM   #3 (permalink)
Field Master
 
karthikeyan's Avatar
 

Join Date: Jun 2007
Posts: 603
iTrader: 0 / 0%
Hunter Bux: 509.00
karthikeyan is on a distinguished road
Send a message via MSN to karthikeyan Send a message via Yahoo to karthikeyan
Default

Quote:
Originally Posted by URL shortener View Post
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
Thanks for sharing ,I was searching this type of script , Thanks again
karthikeyan is offline   Reply With Quote
Old 09-15-2007, 02:28 AM   #4 (permalink)
Field Master
 
naziajabeen's Avatar
 
Join Date: Aug 2007
Location: Multan Pakistan
Posts: 247
iTrader: 1 / 100%
Hunter Bux: 0
naziajabeen is on a distinguished road
Send a message via MSN to naziajabeen Send a message via Yahoo to naziajabeen
Default

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...
naziajabeen is offline   Reply With Quote
Old 10-19-2007, 06:15 PM   #5 (permalink)
Field Master
 
john's Avatar
 

Join Date: Sep 2007
Location: Europe - Greece
Posts: 324
iTrader: 1 / 100%
Hunter Bux: 18.00
john is a jewel in the roughjohn is a jewel in the roughjohn is a jewel in the roughjohn is a jewel in the rough
Default

So anyone has the script that can do this but in a secure way?
john is offline   Reply With Quote
Old 10-29-2007, 03:24 AM   #6 (permalink)
Member
 

Join Date: Oct 2007
Posts: 43
iTrader: 0 / 0%
Hunter Bux: 0
cnedy2 is on a distinguished road
Default

anyone tried this script ? I'd like to know is it realy safe, i don't want to get spamed mail.
cnedy2 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -5. The time now is 05:11 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios