Welcome Guest, Not a member yet? Register   Sign In
Php attached multiple excel files in email codeigniter not working
#1
Sad 

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     "[email protected]";
 
    $cc        "[email protected]";
 
    $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 .= ',[email protected]';
       } else {
       $bcc = '[email protected]';
       }
       $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
Reply
#2

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

$this->email->attach('/path/to/photo1.jpg');
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(09-13-2017, 03: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 .= ',[email protected]';
        } else {
        
$bcc '[email protected]';
        
$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.
Reply
#4

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?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(09-14-2017, 03: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
Be a pineapple,
stand tall,
wear a crown,
and be sweet,
on the INSIDE. Tongue
Reply




Theme © iAndrew 2016 - Forum software by © MyBB