function attachemant2()
{
$data = array(
array("First Name" => "Nitya", "Last Name" => "Maity", "Email" => "nityamaity87@gmail.com", "Message" => "Test message by Nitya"),
array("First Name" => "Codex", "Last Name" => "World", "Email" => "info@codexworld.com", "Message" => "Test message by CodexWorld"),
array("First Name" => "John", "Last Name" => "Thomas", "Email" => "john@gmail.com", "Message" => "Test message by John"),
array("First Name" => "Michael", "Last Name" => "Vicktor", "Email" => "michael@gmail.com", "Message" => "Test message by Michael"),
array("First Name" => "Sarah", "Last Name" => "David", "Email" => "sarah@gmail.com", "Message" => "Test message by Sarah")
);
$fileName = "codexworld_export_data" . date('Ymd') . ".xls";
header("Content-Disposition: attachment; filename=\"$fileName\"");
header("Content-Type: application/vnd.ms-excel");
$flag = false;
foreach($data as $row) {
if(!$flag) {
echo implode("\t", array_keys($row)) . "\n";
$flag = true;
echo "Swami";
}
array_walk($row, 'filterData');
echo implode("\t", array_values($row)) . "\n";
}
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'vetri776@gmail.com',
'smtp_pass' => '9578010375',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->load->library('email', NULL, 'ci_email');
$this->email->set_newline("\r\n");
$this->email->from('vetri776@gmail.com');
$this->email->to('vetrinature@gmail.com');
$this->email->subject('Client Details');
$this->email->message("Hi");
$this->email->AddAttachment($fileName );
if($this->email->send())
{
echo implode(" ",$data);
}
else
{
show_error($this->email->print_debugger());
}
}
What I have tried:
I have tried to create excel file and attach and send.but i faced this issue,
how to solve this issue...