CodeIgniter Forums
large attachment cannot be sent using codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: large attachment cannot be sent using codeigniter (/showthread.php?tid=70120)



large attachment cannot be sent using codeigniter - squashking - 02-24-2018

Hi guys, 

I'm implementing a program of sending email using Codeigniter Email class and gmail smtp. I find it works when the attachment is small (e.g., less than 1MB) but if it's large (e.g., 5MB) then the attachment cannot be sent with the email, though the email itself can be sent without any errors. I checked my host (I'm using Ipage by the way), the attachment is successfully uploaded to the host, so it's not a problem of uploading. I also checked the php.ini on Ipage host, here are relevant parameters, they all seem to be OK:

memory_limit = 256M
max_execution_time = 120
upload_max_filesize = 8M
post_max_size = 20M

I tried using localhost it didn't work with large attachments either.

Could anybody tell me what the problem could be? Thank you very much!
There isn't anything special about the code, but i attach the code below just in case someone wants to see.


PHP Code:
$config['mailtype'] = 'html';
$config['charset'] = 'UTF-8';
$config['newline']    "\r\n";//没有这句话就会出现send没响应的情况
$config['wordwrap'] = TRUE;
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_timeout'] = 30;
$config['smtp_user'] = '******@gmail.com';
$config['smtp_pass'] = '*********';
                            
$this
->load->library('email'); 
$this->email->initialize($config);                                                       
         
            
$this
->email->from('****@gmail.com');                           
$this
->email->to(*****);

$this->email->bcc('******');
$this->email->subject($order->subject);
$this->email->message($order->content);
if(
$order->attach)//if there is attachment
    
$this->email->attach("path/to/attachement");

if(
$this->email->send()) 
{
}
else 
    
$this->email->print_debugger();  



RE: large attachment cannot be sent using codeigniter - InsiteFX - 02-24-2018

Try one of these:

Code:
php.ini

Both of these need to be set to the same size and larger then upload_max_filesize

; Maximum meory size.
memory_limit = 256M

; Must be greater than or equal to upload_max_filesize
post_max_size = 256M

; Maximum allowed size for uploaded files.
upload_max_filesize = 128M



.htaccess:

php_value memory_limit 256M
php_value post_max_size 2560M
php_value upload_max_filesize 128M


user.ini

ini_set('memory_size', '256M');
ini_set('post_max_size', '256M');
ini_set('upload_max_filesize', '128M');

ini_set('max_input_time', 300);
ini_set('max_execution_time', 300);



RE: large attachment cannot be sent using codeigniter - squashking - 02-25-2018

(02-24-2018, 05:11 AM)InsiteFX Wrote: Try one of these:

Code:
php.ini

Both of these need to be set to the same size and larger then upload_max_filesize

; Maximum meory size.
memory_limit = 256M

; Must be greater than or equal to upload_max_filesize
post_max_size = 256M

; Maximum allowed size for uploaded files.
upload_max_filesize = 128M



.htaccess:

php_value memory_limit 256M
php_value post_max_size 2560M
php_value upload_max_filesize 128M


user.ini

ini_set('memory_size', '256M');
ini_set('post_max_size', '256M');
ini_set('upload_max_filesize', '128M');

ini_set('max_input_time', 300);
ini_set('max_execution_time', 300);

Hi InsiteFX, thank you for the answer. But where is user.ini?


RE: large attachment cannot be sent using codeigniter - squashking - 02-26-2018

Eventually I found out the reason. Actually it's not a problem of the size. It's just a problem of the file name. If the file name contains spaces it will fail. But I still haven't got a solution. I think Codeigniter should allow spaces in the attachment path.


RE: large attachment cannot be sent using codeigniter - InsiteFX - 02-26-2018

user.ini you need to create in the root directory

I also answered your filename problem in the other topic.