php - verification register with email using codeigniter -
i tried project verification email there obstacles . when submit data registers error . please give explanations on coding me , went wrong ..... ...... please explanations
controllers :
<?php defined('basepath') or exit('no direct script access allowed'); class register extends ci_controller { public function __construct(){ parent::__construct(); $this->load->model('m_register'); } public function index() { $this->load->helper('form'); $data = array ( 'isi' => 'login/vregister'); $this->load->view('layout/wrapper',$data); } function submit() { //passing post data dari view $_post['dob'] = $_post['year'].'-'.$_post['month'].'-'.$_post['day']; $firstname = $this->input->post('firstname'); $lastname = $this->input->post('lastname'); $password = $this->input->post('password'); $email = $this->input->post('email'); $dob = $this->input->post('dob'); $jkl = $this->input->post('jkl'); $lastlogin = $this->input->post('lastlogin'); //memasukan ke array $data = array( 'firstname' => $firstname, 'lastname' => $lastname, 'password' => $password, 'email' => $email, 'dob' => $dob, 'jkl' => $jkl, 'lastlogin' => $lastlogin, 'active' => 0 ); //tambahkan akun ke database $this->m_register->add_account($data); //redirect(base_url().'homepage/homepage'); $id = $this->m_register->add_account($data); //enkripsi id $encrypted_id = md5($id); $this->load->library('email'); $config = array(); $config['charset'] = 'utf-8'; $config['useragent'] = 'codeigniter'; $config['protocol']= "smtp"; $config['mailtype']= "html"; $config['smtp_host']= "ssl://smtp.gmail.com";//pengaturan smtp $config['smtp_port']= "465"; $config['smtp_timeout']= "400"; $config['smtp_user']= "duwi@gmail.com"; // isi dengan email kamu $config['smtp_pass']= "*******"; // isi dengan password kamu $config['crlf']="\r\n"; $config['newline']="\r\n"; $config['wordwrap'] = true; //memanggil library email dan set konfigurasi untuk pengiriman email $this->email->initialize($config); //konfigurasi pengiriman $this->email->from($config['smtp_user']); $this->email->to($email); $this->email->subject("verifikasi akun"); $this->email->message( "terimakasih telah melakuan registrasi, untuk memverifikasi silahkan klik tautan dibawah ini<br><br>" ); if($this->email->send()) { echo "berhasil melakukan registrasi, silahkan cek email kamu"; }else { echo "berhasil melakukan registrasi, namu gagal mengirim verifikasi email"; } echo "<br><br><a href='".site_url("index.php/login/login")."'>kembali ke menu login</a>"; } }
i use following config send emails on website:
$this->load->library('email'); $config['protocol'] = 'sendmail'; $config['mailpath'] = '/usr/sbin/sendmail'; $config['charset'] = 'utf-8'; $config['mailtype'] = "html"; $this->email->initialize($config);
perhaps try change "protocol" sendmail?
Comments
Post a Comment