email tidak bisa terkirim ke mailtrap.io

saya mau tanya nih.. saat registrasi email tidak bisa terkirim ke mailtrap untuk verifikasi

ini code email.php di folder config



<?php

// setting email from mailtrap.io

$config['protocol']  = 'smtp';
$config['smtp_host'] = 'mailtrap.io';
$config['smtp_port'] = 2525;
$config['smtp_user'] = '2a5e2a9f0913d5';
$config['smtp_pass'] = 'a3d03ce2c94eb5';
$config['crlf']      = "\r\n";
$config['newline']   = "\r\n";

?>

dan ini code Auth.php di controller


<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Auth extends CI_Controller {

	public function __construct(){
		parent::__construct();
		$this->load->model('user_model');
	}

	public function register(){

		$this->form_validation->set_rules('username','Username','required|is_unique[users.username]');
		$this->form_validation->set_rules('email','Email','required|is_unique[users.email]');
		$this->form_validation->set_rules('password','Password','required');
		$this->form_validation->set_rules('password2','Konfirmasi Password','required|matches[password]');

		if ($this->form_validation->run() == false) {

			$this->load->view('layouts/header');
			$this->load->view('auth/register');

		} else {
			$this->user_model->insert_user(); // save user

			// verifikasi email
			$this->send_email_verification($this->input->post('email'), $_SESSION['token']);
			redirect('login');

		}
	}

	public function send_email_verification($email, $token){
		$this->load->library('email');
		$this->email->from('lalurahmanms@gmail.com','Lalu Abdurrahman');
		$this->email->to($email);
		$this->email->subject('Register Aplikasi Auth Local');
		$this->email->message("
				Klik untuk konfirmasi pendaftaran
				<a href='http://localhost/belajarci/auth/verify/$email/$token'>Konfirmasi Email </a>
			");
		$this->email->set_mailtype('html');
		$this->email->send();

	}

}

akun yg di daftar sudah berhasil redirect ke halaman login.

avatar lalurahmanms
@lalurahmanms

1 Kontribusi 0 Poin

Diperbarui 6 tahun yang lalu

1 Jawaban:

Jawaban Terpilih

coba untuk confignya dilengkapin lagi, cek disini <a href='https://www.codeigniter.com/user_guide/libraries/email.html'>https://www.codeigniter.com/user_guide/libraries/email.html</a>

contoh tambahkan <pre> $config['mailpath'] = '/usr/sbin/sendmail'; </pre>

avatar hilmanski
@hilmanski

2686 Kontribusi 2135 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban