public function send_email(){
$email_from = $this->input->post('email_from');
$email_fromname = $this->input->post('email_fname');
$email_to = $this->input->post('email_to');
$subject = $this->input->post('subject');
$message = $this->input->post('message');
if($this->input->post('file_name') !== NULL){
$file_name = base_url('upload/ext_policy/policy/'.$this->input->post('file_name'));
}else{
$file_name = '-';
}
if($this->input->post('file_name2') !== NULL){
$file_name2 = base_url('upload/ext_policy/attach/'.$this->input->post('file_name2'));
}else{
$file_name2 = '-';
}
if($this->input->post('file_name3') !== NULL){
$file_name3 = base_url('upload/ext_policy/reportform/'.$this->input->post('file_name3'));
}else{
$file_name3 = '-';
}
// $file_name = base_url('upload/ext_policy/policy/'.$this->input->post('file_name'));
// $file_name2 = base_url('upload/ext_policy/attach/'.$this->input->post('file_name2'));
// $file_name3 = base_url('upload/ext_policy/reportform/'.$this->input->post('file_name3'));
$config = array(
'mailtype' => 'html',
'charset' => 'utf-8',
'protocol' => 'smtp',
'smtp_host' => 'xxx.xx.xxx.xx',
'smtp_user' => '',
'smtp_pass' => '',
'smtp_port' => '25'
);
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from($email_from, $email_fromname);
$this->email->to($email_to);
$this->email->subject($subject);
$this->email->message($message);
$this->email->attach($file_name);
$this->email->attach($file_name2);
$this->email->attach($file_name3);
$emailsent = $this->email->send();
if($emailsent == TRUE){
return TRUE;
}else{
return $this->email->print_debugger();
}
}
I've scenarios that only send one or two of the 3 files that I've uploaded. but in another scenario, I've to send all 3 files.
my question is Can Codeigniter send an email if one or two of 3 attach method's value set to something(string "-")? will Codeigniter continue sending emails without attaching files? or will Codeigniter error and will not send the whole email?
please, if you know about this help me I can't find the answer on google...
I've tested that code works perfectly on another scenario that I always attach 1 file with the correct path.