Reply
Upload Attachment Email Form using PHPMailer Class - File Size
Old 01-23-2008, 08:12 AM Upload Attachment Email Form using PHPMailer Class - File Size
Novice Talker

Posts: 11
Location: uk
Please help me here, I will try give you as much information as possible!

I have been trying to set up an email form with the feature to upload a file and attach it with the email.

I have got it successfully working but only with files of around 3mb. Now, I have checked everything I could think of with regards to why larger files will not work. I have called my hosting company and they have said it is not the server set up but something to do with the script itself. Whether that is true or not I do not know.

I am using two pages alongside the PHPMailer class.

http://www.pixelpractice.com/work/aep/email/emailform.php

Very simple form pointing to attach.php with the file path in an array.

http://www.pixelpractice.com/work/aep/email/attach.php
Uploads, checks and emails the email with attachement, includes the phpmailer class.

I got the attach.php script from here
http://zainal.wordpress.com/category/php-file-upload/


Hosting. www.1and1.co.uk
SMTP Setting: smtp.1and1.com
PHP Setup http://www.webfroot.co.uk/email/phpinfo.php

Right, as I have mentioned with a file around 2.5 / 3mb there is no problem, it really works well. Now when I try to add a 6mb JPG file the file uploads to the server but the send email function does not seem to process nor does an error occur.

Once the function to check the upload is successful it is calling the function to send the email but nothing happens.

I have turned on SMTP error notification to help diagnose. It should display "Message has been sent" at the end when sent, but seems to hand at "file successfully uploaded"

Attach.php

PHP Code:
<?php
require("class.phpmailer.php");
//Variables Declaration
$name "the Submitter";
$email_subject "Feed Back";
$Email_msg ="A visitor submitted the following :\n";
$Email_to "ryank1978@hotmail.com"// the one that recieves the email
$email_from "ryank1978@hotmail.com";
$dir "uploads/$filename";
chmod("uploads",0777);
$attachments = array();

checkType();

//------Check TYPE------\\    
function checkType() {    
    while(list(
$key,$value) = each($_FILES[images][type])){
        
strtolower($value);
        if(
$value != "image/jpeg" AND  $value != "image/pjpeg" AND $value != "") {
            exit(
'Sorry , current format is <b>'.($value).'</b> ,only Jpeg or jpg are allowed.');
        }
    }
    
    
checkSize();
    
    
}
//-------END OF Check TYPE--------\\



//---CheckSizeFunction ---\\
function checkSize(){
    global 
$result$MV    ,$errors,$BackLink;
    while(list(
$key,$value) = each($_FILES[images][size]))
       {
           
$maxSize 8000000;
                if(!empty(
$value)){
                    if (
$value $maxSize) {
                        echo
"Sorry this is a very big file .. max file size is $maxSize Bytes = 5 MB";
                        exit();
                    }
                    else {
                    
$result =  "File size is ok :)<br>";
                    
                    }
        
        }
        
      }    
        
uploadFile();
    
}
//-------END OF Check Size--------\\





//==============upload File Function============\\

function uploadFile() {
    global 
$attachments;
    while(list(
$key,$value) = each($_FILES[images][name]))
                {
                echo(
"just trying to send it!!!");
                    
                    if(!empty(
$value))
                    {
                            
$filename $value;
                            
array_push($attachments$filename);
                            
$dir "uploads/$filename";
                            
chmod("uploads",0777);
                             
$success copy($_FILES[images][tmp_name][$key], $dir);
                    }
                                
                }
                                            
                               if (
$success) {
                                echo 
" Files Uploaded Successfully<BR>";
                                
SendIt();
    
                                    }else {
                                            exit(
"Sorry the server was unable to upload the files...");
                                        }
                                        
}
                        
                    

                
            

//======================================================================== PHP Mailer With ATtachment Func ===============================\\

function SendIt() {

        global 
$attachments,$name,$Email_to,$Email_msg,$email_subject,$email_from;
        
        
$mail = new PHPMailer();
        
        
$mail->IsSMTP();// send via SMTP
        
$mail->Host     "smtp.1and1.com"// SMTP servers
        
$mail->SMTPAuth false// turn on/off SMTP authentication

        
$mail->From     $email_from;
        
$mail->FromName $name;
        
$mail->AddAddress($Email_to); 
        
$mail->AddReplyTo($email_from);
        
$mail->WordWrap 50;// set word wrap
    
        
foreach($attachments as $key => $value) {  //loop the Attachments to be added ...
        
$mail->AddAttachment("uploads"."/".$value);
        }
        
$mail->Body $Email_msg."Name : ".$name."\n";

        
$mail->IsHTML(false);// send as HTML
        
$mail->Subject  =  $email_subject;
        if(!
$mail->Send())
        {    
           echo 
"Message was not sent <p>";
           echo 
"Mailer Error: " $mail->ErrorInfo;
           exit;
        }
        echo 
"Message has been sent";
        
// after mail is sent with attachments , delete the images on server ...
        //foreach($attachments as $key => $value) {//remove the uploaded files ..
        //        unlink("uploads"."/".$value);
                                //}
        
    
}

?>
Help on this will be most appreciated, I have spent days on this now.
ninja2001k is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 01-23-2008, 08:30 AM Re: Upload Attachment Email Form using PHPMailer Class - File Size
Novice Talker

Posts: 11
Location: uk
I am also open to other recommendations.

Last edited by ninja2001k : 01-25-2008 at 04:20 AM.
ninja2001k is offline
Reply With Quote
View Public Profile
 
Old 01-25-2008, 04:22 AM Re: Upload Attachment Email Form using PHPMailer Class - File Size
Novice Talker

Posts: 11
Location: uk
Help! =)
ninja2001k is offline
Reply With Quote
View Public Profile
 
Old 03-27-2008, 03:27 AM Re: Upload Attachment Email Form using PHPMailer Class - File Size
Junior Talker

Posts: 1
Name: sarjono
If you run this script, just to know your server's PHP configuration:

<?
phpinfo();
?>

In the PHP core configuration, does upload_max_filesize show a limit of around 3Mb?

I am a noob in this too. Perhaps the smtp ran out of resources and halted?
sarj is offline
Reply With Quote
View Public Profile
 
Old 06-30-2008, 12:48 AM Re: Upload Attachment Email Form using PHPMailer Class - File Size
Junior Talker

Posts: 2
Hello, anyone help me,
i try to upload and send file attach mail by phpMailer, and i referencing this source, but always be break in "Sorry the server was unable to upload the files..."

Thanks
dienql is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Upload Attachment Email Form using PHPMailer Class - File Size
 

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13578 seconds with 12 queries