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????

avatar abdulrojakUG
@abdulrojakUG

59 Kontribusi 0 Poin

Diperbarui 6 tahun yang lalu

6 Jawaban:

Halo.

Mas mencobanya di localhost atau live site?

avatar tompradana
@tompradana

134 Kontribusi 95 Poin

Dipost 6 tahun yang lalu

localhost mas

avatar abdulrojakUG
@abdulrojakUG

59 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

@tompradana

avatar abdulrojakUG
@abdulrojakUG

59 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

oh harus coba lewat live site ya , ok ok

avatar abdulrojakUG
@abdulrojakUG

59 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

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.

avatar tompradana
@tompradana

134 Kontribusi 95 Poin

Dipost 6 tahun yang lalu

 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?

avatar abdulrojakUG
@abdulrojakUG

59 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban