嗨,这是我的控制器功能。在我看来,我将一个来自数据库的电子邮件变量设置为会话数据。我在控制器中验证了它是否正确。我得到它完美。但是,当我尝试将该电子邮件 ID 作为 TO 字段变量发送时,它不起作用。
function do_upload()
{
$config['upload_path'] = 'C:\xampp\htdocs\upload\application';
$config['allowed_types'] = 'doc|docx|pdf';
$config['max_size'] = '10240';
$email = $this->session->userdata("employer_email");// If i echo $email; I will get my passed session variable
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
echo "Resume Successfully uploaded to database.............";
$file = $data['upload_data']['full_path'];
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx@gmail.com', // change it to yours
'smtp_pass' => 'xxxx', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('xxx@gmail.com'); // change it to yours
$this->email->to($email); // But here it's not working
$this->email->subject('Email using Gmail.');
$this->email->message('Working fine ! !');
$this->email->attach($file);
if($this->email->send())
{
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
}
}