Unable to send email using PHP mail().

Halo semuanya gini saya masih awam banget, jd ada eror dalam ngirim email

udah baca bbrpa sumber tetap saja begitu 'Unable to send email using PHP mail(). Your server might not be configured to send mail using this method'

ini kodingan usermodel.php saya

  $this->load->library('email');

 if($this->config->item('protocol')=="smtp"){
			$config['protocol'] = 'smtp';
			$config['smtp_host'] = $this->config->item('smtp_hostname');
			$config['smtp_user'] = $this->config->item('smtp_username');
			$config['smtp_pass'] = $this->config->item('smtp_password');
			$config['smtp_port'] = $this->config->item('smtp_port');
			$config['smtp_timeout'] = $this->config->item('smtp_timeout');
			$config['mailtype'] = $this->config->item('smtp_mailtype');
			$config['wordwrap']  = $this->config->item('wordwrap');
			 $config['newline']  = $this->config->item('newline');
			$config['charset']  = $this->config->item('charset');

			$this->email->initialize($config);
		}
			$fromemail=$this->config->item('fromemail');
			$fromname=$this->config->item('fromname');
			$subject=$this->config->item('activation_subject');
			$message=$this->config->item('activation_message');;

			$message=str_replace('[verilink]',$verilink,$message);

			$toemail=$this->input->post('email');

			$this->email->to($toemail);
			$this->email->from($fromemail, $fromname);
			$this->email->subject($subject);
			$this->email->message($message);
			if(!$this->email->send()){
			show_error($this->email->print_debugger());
			}
			else
			{
				echo 'Email sent.';
			}


			 }

			return true;
		}else{

			return false;
		}

 }







 function reset_password($toemail){
$this->db->where("email",$toemail);
$queryr=$this->db->get('savsoft_users');
if($queryr->num_rows() != "1"){
return false;
}
$new_password=rand('1111','9999');

 $this->load->library('email');

 if($this->config->item('protocol')=="smtp"){
			$config['protocol'] = 'smtp';
			$config['smtp_host'] = $this->config->item('smtp_hostname');
			$config['smtp_user'] = $this->config->item('smtp_username');
			$config['smtp_pass'] = $this->config->item('smtp_password');
			$config['smtp_port'] = $this->config->item('smtp_port');
			$config['smtp_timeout'] = $this->config->item('smtp_timeout');
			$config['mailtype'] = $this->config->item('smtp_mailtype');
			$config['starttls']  = $this->config->item('starttls');
			 $config['newline']  = $this->config->item('newline');
			 $config['charset']  = $this->config->item('charset');

			$this->email->initialize($config);
		}
			$fromemail=$this->config->item('fromemail');
			$fromname=$this->config->item('fromname');
			$subject=$this->config->item('password_subject');
			$message=$this->config->item('password_message');;

			$message=str_replace('[new_password]',$new_password,$message);



			$this->email->to($toemail);
			$this->email->from($fromemail, $fromname);
			$this->email->subject($subject);
			$this->email->message($message);
			if(!$this->email->send()){
			 //print_r($this->email->print_debugger());

			}else{
			$user_detail=array(
			'password'=>md5($new_password)
			);
			$this->db->where('email', $toemail);
 			$this->db->update('savsoft_users',$user_detail);
			return true;
			}

}


sedangkan ini config.php



// smtp hostname eg. smtp.gmail.com
$config['smtp_hostname'] = "ssl://smtp.gmail.com";
// smtp username
$config['smtp_username'] = "xxx@gmail.com";
// smtp password
$config['smtp_password'] = "xxxx";
// smtp outgoing port. eg for gmail its 465, outlook 587, yahoo 465 for other contact your mailing administrator
$config['smtp_port'] = "465";
// smtp timeout default 5 seconds
$config['smtp_timeout'] = "5";
// email message content text of html.
// In html email make sure you don't have any relative links or relative image paths otherwise they will not work.
$config['smtp_mailtype'] = "html";
// smtp wordwrap
$config['wordwrap'] = TRUE;
// new line
$config['newline'] = "\r\n";
$config['charset']= "iso-8859-1";

// activation email subject
$config['activation_subject'] = "Action required to verify your account";
// activation email message
$config['activation_message'] = "Hi, \r\n Thank you for registering with us. Please click below link to verify your email address.\r\n <a href='[verilink]'>[verilink]</a> \r\n or \r\n Copy below link and visit in browser \r\n [verilink] \r\n \r\n Thanks";

// password reset email subject
$config['password_subject'] = "Password Changed";
// password reset email message
$config['password_message'] = "Hi, \r\n Your New Password is: [new_password] \r\n Thanks";

// Default result message
// you can use below tags and system replace it with related variables.
// [username] [email] [first_name] [last_name] [score_obtained] [percentage_obtained] [result_status] [quiz_name] [current_date]
$config['result_message'] = "Hi [last_name],\r\n \r\n  You have [result_status]  Quiz: '[quiz_name]' and obtained [percentage_obtained]% marks. To get more information please login to your quiz portal.\r\n  \r\n  Thanks";
// result email subject
$config['result_subject'] = "Result generated for quiz [quiz_name]";

// email send from
$config['fromemail']="noreply@gmailll.com";
// from name
$config['fromname']="Administrator - Quiz Portal";


avatar Juniorjunior
@Juniorjunior

4 Kontribusi 0 Poin

Diperbarui 3 tahun yang lalu

1 Jawaban:

<div>Kirim email ke google. Tanya ke mereka kenapa error. Nanti mereka jawab: Hehehe, kena lu ye.... :-)</div>

avatar ahmadarief
@ahmadarief

1 Kontribusi 0 Poin

Dipost 3 tahun yang lalu

Login untuk ikut Jawaban