CodeIgniter Forums
Email attachments unable to locate files - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Email attachments unable to locate files (/showthread.php?tid=37151)



Email attachments unable to locate files - El Forum - 12-29-2010

[eluser]Ngulo[/eluser]
Hi guys,

i'm trying sending attachments files in email :

all is working but and email arrives but attachments shows this error:
Code:
Unable to locate the following email attachment: http://www.asd.com/files/file.pdf

if i go to file url (http://www.asd.com/files/file.pdf ) by browser i can see that file!! Sad

anyone can help me?

my email script is simple:

Code:
if($_FILES['bill_file']['tmp_name'] and $_FILES['bill_file']['name'])
            {
                     if($this->input->post('email_for_bill',true)){
                     $billTemp = htmlentities($_FILES['bill_file']['tmp_name']);
                     $bill = htmlentities($_FILES['bill_file']['name']);
                  //  if(move_uploaded_file($billTemp,'uploads/orders/bills/'.$bill))
                    //{

                      $this->load->library('email');
                       $config['charset'] = 'iso-8859-1';
                       $config['mailtype'] = 'html';

                      $this->email->initialize($config);
                      
                      $this->email->from($this->config->config['email_from'],$this->config->config['email_sender_sitename']);
                      $this->email->to($this->input->post('email_for_bill',true));
                      $this->email->subject("my order n ".$id."(Order Bill)");
                      $this->email->message('asdasd');
                      $this->email->attach(base_url().'uploads/orders/bills/'.$bill);

                      $this->email->send();

                      unset($data);
                      $data = array('bill_sent'=>'1');
                      $this->order_bills->update($id,$data);
                    }
                   //  }
                    
            }//end upload + email attachment send

echo $this->email->print_debugger();

so just to explain my script, first of all i upload and move file into main folder, then i create email , take created file and attach that to email and in the end i send email...

my folders are all 775 Sad

really don't know why anytime the file is created but not attached Sad

thanks to anyone can help me guys Wink


Email attachments unable to locate files - El Forum - 12-30-2010

[eluser]Atharva[/eluser]
That's coz you are using absolute path. You need to use relative path. See following statement from the guide
Quote:Note: Use a file path, not a URL.
Code:
$this->email->attach('/path/to/photo1.jpg');



Email attachments unable to locate files - El Forum - 01-01-2011

[eluser]Ngulo[/eluser]
thanks man!!! solved Smile

really thanks