CodeIgniter Forums
Php attached multiple excel files in email codeigniter not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Php attached multiple excel files in email codeigniter not working (/thread-68907.html)



Php attached multiple excel files in email codeigniter not working - Var91 - 09-12-2017

I want to attach two excel files (sealing_production.xls & sealing_assembly.xls)to my email using php,but I have no idea on how to do it. Confused

Can anybody help me please?? Big Grin Big Grin 

Problem
When I click on my send mail button, I gets the mail. with all details. but attachment is not working.

Try
1.I echo the file name, its prints the file name from controller
2.I also try to put

Code:
$this-> email -> attach($file);



in my model


and also this in my sendEmail function

Code:
$this -> global_model -> sendfullmail($user, $subject, $content,$cc, '',$xls);


but the email that i receive is only blank email without content.
Here my php code for the send Email function



PHP Code:
function sendEmail() {
 
    $user     "dheanas@gmail.com";
 
    $cc        "as@gmail.com";
 
    $status     "Dear All,";
 
    $date date("y-m-d") ;
 
    $xls        "Sealing Report/{$date}/sealing_production.xls";
 
    $xls1        "Sealing Report/{$date}/sealing_assembly.xls";
 
    $subject   "Sealing Daily Production & Daily Output Report ";
 
     $content   "<p>{$status}</p>
                    <p>
                    <p>Please find the attached files of Sealing Daily Production 
                         & Daily Output Report</p> 
                    <p>for your reference and further actions.</p> 
                    <br><p>Thank you very much. </p>
                    <p>This is Computer Generated Email, please do not reply. </p></br>"
;
 
   $this -> global_model -> sendfullmail($user$subject$content,$cc'');  



and this the function of sendfullmail in my model:

Code:
//send out full email include cc and bcc
   function sendfullmail($receipient, $title, $message,$cc,$bcc){
       $this -> load -> library('email');
       $this -> email -> from($this -> from, $this ->fromname);
       $this -> email -> to($receipient);
       $this -> email -> cc($cc);
       $this -> email -> set_alt_message($this -> alt);
       if ($bcc != '') {
       $bcc .= ',sindisystem@gmail.com';
       } else {
       $bcc = 'sindisystem@gmail.com';
       }
       $this -> email -> bcc($bcc);
       $this -> email -> subject($title);
       $this -> email -> message($message);
       $this -> email -> send();
   }

What I have tried:


I have check similar links on stack overflow about this. But i'm unable to find any solution for this.
Link's i have checked
  1. Codeigniter send email with attach file
  2. Code Igniter -> attach email
  3. codeigniter send pdf file as email attachment
  4. How To Send Email With An Attachment In Codeigniter?
  5. How to attach two or multiple files and send mail in PHP



RE: Php attached multiple excel files in email codeigniter not working - InsiteFX - 09-13-2017

And where are you using this statement in your sendfullmail()?

$this->email->attach('/path/to/photo1.jpg');


RE: Php attached multiple excel files in email codeigniter not working - Var91 - 09-13-2017

(09-13-2017, 04:59 AM)InsiteFX Wrote: And where are you using this statement in your sendfullmail()?

$this->email->attach('/path/to/photo1.jpg');

Hi,
I try to change my sendfullmail into below

PHP Code:
function sendfullmail($receipient$title$message,$cc,$bcc,$file){
        
$this -> load -> library('email');
        
        
$this -> email -> from($this -> from$this ->fromname);
        
$this -> email -> to($receipient);
        
$this -> email -> cc($cc);
        
$this -> email -> set_alt_message($this -> alt);
        
        if (
$bcc != '') {
        
$bcc .= ',sindisystem@sindigroup.com';
        } else {
        
$bcc 'sindisystem@sindigroup.com';
        
$this->email->attach($file);
        }
        
$this -> email -> bcc($bcc);
        
$this -> email -> subject($title);
        
$this -> email -> message($message);
        
$this -> email -> attach($file);
        
$this -> email -> send();
        
    } 


and  add this in my sendEmail()

PHP Code:
$this -> global_model -> sendfullmail($user$subject$content,$cc'',$xls1); 
but the email that I get is only a blank email.


RE: Php attached multiple excel files in email codeigniter not working - InsiteFX - 09-14-2017

I got your message but I cannot reply to you because you have Private Messages turned OFF!

Are you sending this to a live server or localhost?


RE: Php attached multiple excel files in email codeigniter not working - Var91 - 09-14-2017

(09-14-2017, 04:37 AM)InsiteFX Wrote: I got your message but I cannot reply to you because you have Private Messages turned OFF!

Are you sending this to a live server or localhost?

I'm sending this to a live server... Big Grin Big Grin