Results 1 to 6 of 6

Thread: Question on PHP Mail Form

  1. #1
    Join Date
    Dec 2005
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Question on PHP Mail Form

    I currently have a couple php mail forms I created, but I am completely lost when it comes to trying to get an attachment sent to. Does anyone have a good PHP form where people can upload and image, dozument, zip file, ect. to the server and mail it to me. The mail form will be set to ALWAYS be sent to me since it is coming from my site, but I am not sure how to add the attach a document function in. If anyone knows this, please help, and THANKS in advance.

    Thanks,
    Justin St. Germain

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You need to be fairly familiar with how MIME headers work. See http://codewalkers.com/seecode/98.html for an example.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Dec 2005
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    You need to be fairly familiar with how MIME headers work. See http://codewalkers.com/seecode/98.html for an example.
    I understand the MIME headers, but not sure how to use them for the attachment, but i will look at that script in the mean time. I however did find a way to actually make a file attachment upload to my server in a hidden file that is protected by .htaccess, and it seems to work quite nice, but i will look at this too. thanks for your help

  4. #4
    Join Date
    Dec 2005
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i still am confused as how to make that work, so i am going to go with having it upload the files to my server unless you know where i can get a full working script where i just need to mod the info on where it is having the mail sent. thanks again for the help.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Try this. It's an easy-to-use class. Don't forget to check out the documentation.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Dec 2005
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i have a php mail form already that i made that works great, but I cant seem to figure out how to get it to upload the file to the listed directory on my site when someone attaches a file. i would rather have it actually send it in the mail instead of uploading to my server, but cant figure that one out either. the only reason i have been stuck on uploading to the file was because i have a script i found that allows me to do that, but cant figure out what i am doing wornge when trying to add just that feature to my current script. if you know the MIME header stuff well enough and can get it to actually just send me the mail without having to uploa to the server, let me know. here is my current code, maybe you can help fix it so it works.

    PHP Code:
    <?

    $mailto 
    'jstgermain@methodcomptech.com' ;

    $subject "MCT Web Mail" ;

    $formurl "http://www.methodcomptech.com/methodemail.html" ;
    $errorurl "http://www.methodcomptech.com/error.html" ;
    $thankyouurl "http://www.methodcomptech.com/success.html" ;

    $name $_POST['name'] ;
    $email $_POST['email'] ;
    $phone $_POST['phone'] ;
    $website $_POST['website'] ;
    $comments $_POST['comments'] ;
    $http_referrer getenv"HTTP_REFERER" );

    if (!isset(
    $_POST['email'])) {
        
    header"Location: $formurl);
        exit ;
    }
    if (empty(
    $name) || empty($email) || empty($comments)) {
       
    header"Location: $errorurl);
       exit ;
    }
    if (
    get_magic_quotes_gpc()) {
        
    $comments stripslashes$comments );
    }

    $messageproper =

        
    "This message was sent from:  " $name 
        
    "\n$http_referrer\n\n" .
        
    "________________________( COMMENTS )________________________\n\n" .
        
    "\nName:  " $name .
        
    "\nE-Mail:  " $email .
        
    "\nPhone Number:  " $phone .
        
    "\nWeb-Site:  " $website .
        
    "\n\nMessage:  \n" $comments .
        
    "\n\n____________________________________________________________\n" ;

    // --THIS IS THE CODE I ADDED TO TRY AND GET IT TO UPLOAD THE FILE, HAS TO BE SOMETHING WRONGE HERE-- //
        
    $up_full "http://www.methodcomptech.com/upload";
        
    $up_dir "./upload/";
        
    $UploadNum "1";
        
    $online_isp "0";    

        
    $status    '';
        
    $new_name  '';
        
    $uploaded  '';
        
    $get_files '';
        
    $all_names '';
        
        for(
    $i=0;$i<count($_FILES["fileup"]["tmp_name"]);$i++)
        {
            
    $name=$_FILES["fileup"]["name"][$i];
            
    $temp=$_FILES["fileup"]["tmp_name"][$i];
            
    $size=$_FILES["fileup"]["size"][$i];
            
    $type=$_FILES["fileup"]["type"][$i];
            if(
    $size 0)
            {
                global 
    $up_dir$all_names;
                
          
    $length    1;
          
    $key_chars '';
          
    $rand_max  strlen($key_chars);
          
          for (
    $i 0$i $length$i++)
          {
             
    $rand_pos  rand(0$rand_max);
             
    $rand_key[] = $key_chars{$rand_pos};
          }
          
    $rand_pass implode(''$rand_key);
          
    $boom strlen($Msg) * strlen($From);
          
    $timer time()* rand(0$boom);
          
    $timer =  $timer '-' .  $rand_pass;

                
    $new_name $name;
                
    $new_name str_replace(" ","_",$new_name);
                @
    move_uploaded_file($temp$up_dir $new_name);
                
    $all_names.= "$new_name\n";
            }
        }
    // -------------------------------------END OF THE ADDED CODE---------------------------------------- //



    mail($mailto$subject$messageproper"From: \"$name\" <$email>\nReply-To: \"$name\" <$email>\nX-Mailer: feedback.php" );
    header"Location: $thankyouurl);
    exit ;

    ?>
    please let me know if anyone out there knows what I did wronge. I can't figure it out.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •