Postingan lainnya
kirim email mengunakan codeigniter
public function forgot_password(){
$method = $_SERVER['REQUEST_METHOD'];
if($method != 'POST'){
$jsonAr = array(
"_meta" => array('status' => 'ERROR','count' => 1),
"result" => array('errorCode' => 400,'userMessage' => 'Bad request')
);
json_output(400,$jsonAr);
} else {
$CI =& get_instance();
$CI->load->model('auth/user/m_user');
$CI->load->model('security/m_security');
$check_auth_client = $this->m_security->check_auth_client();
if($check_auth_client == true){
$params = $_REQUEST;
$params['email_user'] = $this->input->post('email_user');
if ($params['email_user'] == "") {
$jsonAr = array(
"_meta" => array('status' => 'ERROR','count' => 1),
"result" => array('errorCode' => 400,'userMessage' => 'Email must be filled')
);
json_output(400,$jsonAr);
} else if (!filter_var($params['email_user'], FILTER_VALIDATE_EMAIL)) {
$jsonAr = array(
"_meta" => array('status' => 'ERROR','count' => 1),
"result" => array('errorCode' => 400,'userMessage' => 'Email is not in a correct form')
);
json_output(400,$jsonAr);
}else{
$response = $this->m_user->getByEmail($params['email_user']);
if ($response['errorCode'] == 200) {
$stat = "SUCCESS";
} else {
$stat = "ERROR";
}
$count = array($response);
if ($response['errorCode'] == 200) {
$result = array($response);
$date_create_token = date('Y-m-d H:i:s');
$token = md5(time() . mt_rand(1,1000000)) . CRC32(time() . mt_rand(1,1000000).$date_create_token);
$links = site_url("v1/user/reset/token/".$tokenstring);
$this->load->library('email');
$htmlContent = "
Token ini berlaku untuk 2 jam dari pengiriman token ini:
Klik disini untuk reset password anda : <a href='$links' style='background-color: #ff5722; border-collapse: separate; border-top: 20px solid #ff5722; border-right: 20px solid #ff5722; border-bottom: 20px solid #ff5722; border-left: 20px solid #ff5722; border-radius: 3px; color: #FFFFFF; display: inline-block; font-family: Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 16px; font-weight: 600; letter-spacing: .3px; text-decoration: none' target='_blank' rel='noreferrer'>Reset Password</a>
";
$$author = "mail@cipta.com";
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->to($params['email']);
$this->email->from($author);
$this->email->subject('Activate Your CodeLoka Account');
$this->email->message($htmlContent);
$this->email->send();
date_default_timezone_set("Asia/Jakarta");
} else {
$result = $response;
}
$jsonAr = array(
"_meta" => array('status' => $stat,'count' => count($count)),
"result" => $result
);
json_output($response['errorCode'],$jsonAr);
}
} else {
$jsonAr = array(
"_meta" => array('status' => 'ERROR','count' => 1),
"result" => array('errorCode' => 401,'userMessage' => 'Unauthorized')
);
json_output(401,$jsonAr);
}
}
}
pada bagian kirim email kenapa engga terkirim ya pesannya????
0
6 Jawaban:
Halo.
Mas mencobanya di localhost atau live site?
0
oh harus coba lewat live site ya , ok ok
0
Halo.
Kalau di localhost juga bisa mas, kita memanfaatkan sendmail pada xampp, namun sebelum bisa menjalankan sendmail, harus ada konfigurasi yang harus disesuaikan terlebih dahulu.
0
if ($response['errorCode'] == 200) {
$result = array($response);
$date_create_token = date('Y-m-d H:i:s');
$token = md5(time() . mt_rand(1,1000000)) . CRC32(time() . mt_rand(1,1000000).$date_create_token);
$links = site_url("v1/user/reset/token/".$tokenstring);
$this->load->library('email');
$htmlContent = "
Token ini berlaku untuk 2 jam dari pengiriman token ini:
Klik disini untuk reset password anda : <a href='$links' style='background-color: #ff5722; border-collapse: separate; border-top: 20px solid #ff5722; border-right: 20px solid #ff5722; border-bottom: 20px solid #ff5722; border-left: 20px solid #ff5722; border-radius: 3px; color: #FFFFFF; display: inline-block; font-family: Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 16px; font-weight: 600; letter-spacing: .3px; text-decoration: none' target='_blank' rel='noreferrer'>Reset Password</a>
";
$author = "mail@cipta.com";
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->to($params['email']);
$this->email->from($author);
$this->email->subject('Activate Your CodeLoka Account');
$this->email->message($htmlContent);
$this->email->send();
date_default_timezone_set("Asia/Jakarta");
jadi bagian author engga perlu ya? hapus aja?
0