I am trying to send email from live server using domain email id. I tried with different port id, every time I got same error.My controller code is given below:
public function send_mail() {
$this->load->library('email');
$name = $this->input->post("name");
$email = $this->input->post("email");
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'mail.*******.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = 'info@*******.com';
$config['smtp_pass'] = '*********';
$config['charset'] = 'utf-8';
$config['newline'] = '\r\n';
$config['mailtype'] = 'text'; // or html
$config['validation'] = TRUE;
$this->email->initialize($config);
$this->email->from('info@*******.com', 'Hima');
$this->email->to($email);
$this->email->subject('email verification');
$this->email->message('Verification Code');
$send = $this->email->send();
if ($send) {
$this->session->set_flashdata('msg','success');
} else {
echo $error = $this->email->print_debugger();
}
}
$this->load->library('email');
//SMTP & mail configuration
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'example@gmail.com',
'smtp_pass' => 'password',
'mailtype' => 'html',
'charset' => 'utf-8'
);
$this->email->initialize($config);
$this->email->from('info@*******.com', 'Hima');
$this->email->to($email);
$this->email->subject('email verification');
$this->email->message('Verification Code');
$send = $this->email->send();
if ($send) {
$this->session->set_flashdata('msg','success');
} else {
echo $error = $this->email->print_debugger();
}
I have configured like following :
public function send_mail() {
$this->load->library('encrypt');
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com',
'smtp_port' => '465',
'smtp_user' => '*****@gmail.com',
'smtp_pass' => '**********',
'smtp_crypto' => 'ssl',
'crlf' => "\r\n",
);
$this->load->library('email',$config);
$send = $this->email->send();
if ($send) {
return $send;
} else {
$error = show_error($this->email->print_debugger());
return $error;
}
}
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.