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.
Problem
When I click on my send mail button, I gets the mail. with all details. but attachment is not working.
Try
I echo the file name, its prints the file name from controller
Here my php code for the send Email function
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:
//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
6.Multiple e-mail attachments
I also try to put
$this-> email -> attach($file);
in my model
and also this in my sendEmail function
$this -> global_model -> sendfullmail($user, $subject, $content,$cc, '',$xls);
but the email that i receive is only blank email without content.