trying to make a reset password function for my website however I cant get past sending an email without this error occuring.
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
I am using gmail as the host to send the email. Here is the part of the function that is used to send the email.
$user_email = $this->input->post('email_address');
$query = $this->db->get_where('account', array('email_address' => $user_email));
if($query) {
$config['protocal'] = 'smtp';
$config['mail_path'] = 'ssl://smtp.googlemail.com';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'USEREMAIL';
$config['smtp_pass'] = 'PASSWORD';
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['newline'] = "\r\n";
$this->email->initialize($config);
$this->email->from('matthew.attanasio135@gmail.com', 'Matthew');
$this->email->to($user_email);
$this->email->subject('Email Test');
$this->email->message('<h1>Testing the email class.<h1>');
$this->email->send();
if ( ! $this->email->send()) {
show_error($this->email->print_debugger());
}
else {
echo('DONE');
}
I am also getting this error::
Message: Undefined index: Subject
I do not understand why this is happening could you please help me out thank you.
try this
You're trying to send the email twice, the first time all your options are set and the second they aren't
change
to
You should then get relevant errors if any remain.
Edit:
also change
$config['protocal']
to$config['protocol']
to fix the sending problemCan you give the rest of the function you're using to send the email, everything you've posted looks correct... the
Message: Undefined index: Subject
is coming from somewhere else and might be causing problems.Also... this may seem obvious, but you have actually loaded the email class somewhere, right (
$this->load->library('email);
)... rather than just initialized it?