otp via mail
This commit is contained in:
parent
f509de5748
commit
ee124cbd61
@ -329,13 +329,18 @@ class Login_model extends CI_Model
|
||||
|
||||
{
|
||||
$result['loginstudent'] = true;
|
||||
$this->db->select('LO.MobileNumber, LO.ListCode, LO.ID,ST.BranchCode, ST.LoginAccess');
|
||||
$this->db->select('LO.MobileNumber, LO.ListCode, LO.ID,ST.BranchCode, ST.LoginAccess,ST.EmailID');
|
||||
$this->db->from('' . LOGIN . ' as LO');
|
||||
$this->db->join('' . STUDENTS . ' as ST', 'LO.StaffID = ST.StudentID');
|
||||
$this->db->where('LO.MobileNumber', $mobile);
|
||||
$this->db->where('ST.IsActive', 1);
|
||||
$responseDetails = $this->db->get()->first_row();
|
||||
|
||||
if($responseDetails->LoginAccess ==1){
|
||||
|
||||
$EmailID = $responseDetails->EmailID;
|
||||
|
||||
|
||||
$string2 = str_shuffle('1234567890');
|
||||
$otp = substr($string2,0,6);
|
||||
//$otp = '431528';
|
||||
@ -350,6 +355,8 @@ class Login_model extends CI_Model
|
||||
// $query =1;
|
||||
if($query == 1){
|
||||
$sms = $this->smssend($mobile,$otp);
|
||||
|
||||
$mail = $this->mailsend($EmailID,$otp);
|
||||
|
||||
$result['checkstudent'] = true;
|
||||
}else{
|
||||
@ -444,6 +451,66 @@ class Login_model extends CI_Model
|
||||
curl_close($ch);
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function mailsend($EmailID,$otp) {
|
||||
$emails = array();
|
||||
|
||||
$list = $EmailID;
|
||||
//Load email library
|
||||
$this->load->library('email');
|
||||
//SMTP & mail configuration
|
||||
$config = array(
|
||||
'protocol' => 'smtp',
|
||||
'smtp_host' => 'smtp.sendgrid.net',
|
||||
'smtp_port' => 587,
|
||||
'smtp_user' => 'apikey',
|
||||
'smtp_pass' => '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',
|
||||
'mailtype' => 'html',
|
||||
'charset' => 'utf-8'
|
||||
);
|
||||
$this->email->initialize($config);
|
||||
$this->email->set_mailtype("html");
|
||||
$this->email->set_newline("\r\n");
|
||||
// print_r($this->email);exit();
|
||||
//Email content
|
||||
// $htmlContent = '<h1>Sending email via SMTP server</h1>';
|
||||
$htmlContent = 'Your OTP for login ApolloDEC is '.$otp;
|
||||
// $htmlContent = $msg;
|
||||
// Email body load the html template
|
||||
// $body = $this->load->view('emails/anillabs.php',$data,TRUE);
|
||||
$this->email->to($list);
|
||||
$this->email->from('noreply@apollodec.com','Apollo');
|
||||
$subj = 'OTP For Login';
|
||||
$this->email->subject($subj);
|
||||
$this->email->message($htmlContent);
|
||||
//Send email 1
|
||||
$result = $this->email->send();
|
||||
|
||||
$time = date('Y-m-d H:i:s');
|
||||
$dateTime = $time;
|
||||
$msgGroup = date('YmdHis');
|
||||
|
||||
|
||||
$data[] = array('MobileNumber' => $list, 'MsgBody' => $htmlContent, 'Status' => 'success', 'CreatedOn' => $dateTime,'MsgGroup' => $msgGroup);
|
||||
|
||||
|
||||
$this->db->insert_batch('T_BroadcastStatus', $data);
|
||||
|
||||
// echo $this->email->print_debugger(); exit();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* End the function*
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user