email - codeigniter query gives error -
i writing code email following query, gives me error:
undefined variable email
it seems result generated query can't seen outside of foreach loop, want email variable. error in send_session_close_mail()
function:
$qry="select email end_employee_master id=(select eemp_id book_e_counseling_mst caseid='ec-".$cid."')" ; $query=$this->db->query($qry); $num=$query->num_rows(); foreach($query->result() $row) { $email=$row->email; }
full code listing:
<?php class email_model extends ci_model { private $config = null; public function __construct() { parent::__construct(); $this->load->helper(array('form', 'url')); $this->load->library('email'); $this->config = array( 'protocol' => 'smtp', 'smtp_host' => 'mail.santulan.co.in', 'smtp_port' => 25, 'smtp_user' => 'no.reply@santulan.co.in', // change yours 'smtp_pass' => 'admin@123', // change yours 'mailtype' => 'html', 'charset' => 'iso-8859-1', 'wordwrap' => true ); $this->email->initialize($this->config); } public function send_password_reset_mail($new_pass, $email) { $base_url = base_url(); $this->email->initialize($this->config); $message_str = '<p><span style="font-family: \'tahoma\', tahoma; font-weight:normal;">hello there,</span></p> <p><span style="font-family: \'tahoma\',tahoma; font-weight:normal;">you have requested reset password. please click on below link. </span></p> <p><span style="font-family: \'tahoma\', tahoma; font-weight:normal;"><a href="' . $base_url . 'index.php/login/reset_password?id=' . $new_pass . '" target="_blank">click here</a></span></p> <p><span style="font-family: \'tahoma\', tahoma; font-weight:normal;">please not share link else.</span></p> <p> </p> <p><span style="font-weight:normal; font-family: \'tahoma\', tahoma;">sincerely,</span></p> <p><span style="font-weight:normal; font-family: \'tahoma\', tahoma;">team santulan </span></p> <p><br /> </p>'; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject('message santulan: password reset link'); $this->email->message($message_str); $this->email->send(); } /** function change password of team **/ public function send_password_reset_mail_team($new_pass, $email) { $base_url = base_url(); $this->email->initialize($this->config); $message_str = '<p><span style="font-family: \'tahoma\', tahoma; font-weight:normal;">hello there,</span></p> <p><span style="font-family: \'tahoma\',tahoma; font-weight:normal;">you have requested reset password. please click on below link. </span></p> <p><span style="font-family: \'tahoma\', tahoma; font-weight:normal;"><a href="' . $base_url . 'index.php/login/reset_password_team?id=' . $new_pass . '" target="_blank">click here</a></span></p> <p><span style="font-family: \'tahoma\', tahoma; font-weight:normal;">please not share link else.</span></p> <p> </p> <p><span style="font-weight:normal; font-family: \'tahoma\', tahoma;">sincerely,</span></p> <p><span style="font-weight:normal; font-family: \'tahoma\', tahoma;">team santulan </span></p> <p><br /> </p>'; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject('message santulan: password reset link'); $this->email->message($message_str); $this->email->send(); } /** * send mail counselor conversation has been * updated user e-counseling case. * @param type $data case id description etc. */ public function set_ec_notify_mail_counselor($data) { $this->load->model('users'); $userdata = $this->users->get_end_employee_detail($data['eemp_id']); $counselordata = $this->users->get_counselor_detail($data['counseler_id']); if ($userdata && $counselordata) { $mailsubject = "e-counseling conversation reply case id " . $data['caseid'] . "."; $mailbody = '<p>hi ' . $counselordata->name . ',</p> <p>greeting day.</p> <p>you have new reply e-counseling case id ' . $data['caseid'] . ' feedback conversation. reply employee ' . $userdata->name . ' ' . $userdata->lname . '. please login <a href="http://www.santulan.co.in" target="_blank" title="http://www.santulan.co.in" name="http://www.santulan.co.in">http://www.santulan.co.in</a> respond this.</p> <p> </p> <p><span style="font-weight:normal;">thanks & regards,</span></p> <p><span style="font-weight: normal;">santulan support team</span></p>'; $this->email->initialize($this->config); $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($counselordata->email); $this->email->subject($mailsubject); $this->email->message($mailbody); $this->email->send(); } } /** * send mail counselor conversation has been * updated user e-counseling case. * @param type $data case id description etc. */ public function set_ec_notify_mail_enduser($data) { $this->load->model('users'); $userdata = $this->users->get_end_employee_detail($data['eemp_id']); $counselordata = $this->users->get_counselor_detail($data['counseler_id']); if ($userdata && $counselordata) { $mailsubject = "e-counseling conversation reply case id " . $data['caseid'] . "."; $mailbody = '<p>hi ' . $userdata->name . ' ' . $userdata->lname . ',</p> <p>greeting day.</p> <p>you have new reply e-counseling case id ' . $data['caseid'] . ' feedback conversation. reply counselor ' . $counselordata->name . '. please login <a href="http://www.santulan.co.in" target="_blank" title="http://www.santulan.co.in" name="http://www.santulan.co.in">http://www.santulan.co.in</a> respond this.</p> <p> </p> <p><span style="font-weight:normal;">thanks & regards,</span></p> <p><span style="font-weight: normal;">santulan support team</span></p>'; $this->email->initialize($this->config); $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($counselordata->email); $this->email->subject($mailsubject); $this->email->message($mailbody); $this->email->send(); } } public function send_feedback_mail($case_id, $emailid, $fname, $lname) { $base_url = base_url(); $this->email->initialize($this->config); $message_str = '<pre><em><strong>hello $fname end user why want feedback me cant call me or dont hav' . ' enough balance in phone. clik on link below http://www.santulan/feedback/feedback_form?case_id=ec-12&emp_id=2&c_id</strong></em></pre>'; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($emailid); $this->email->subject('santulan-feedback email'); $this->email->message('$message_str'); $email->send(); } /**public function send_session_details($output) { $base_url = base_url(); $this->email->initialize($this->config); $case_id = $output['caseid']; $sessiondetail = $output['currentsessiondetails']; $query = " select email end_employee_master id=(select eemp_id book_e_counseling_mst caseid='$case_id')"; $result = $this->db->query($query); foreach ($result->result() $row) { $mail_id = $row->email; } $message_str = '<pre><em><strong>hello counseler have new case</strong></em></pre>'; $this->email->from('no.reply@santulan.co.in', 'santulan team'); $this->email->to($mail_id); $this->email->subject('counselor have new case come on'); $this->email->message($message_str); $this->email->send(); }**/ public function send_helpline_registration_mail($gvfcode,$data,$password) { $base_url = base_url(); $this->email->initialize($this->config); $email = $data['email']; $firstname = $data['name']; $lastname = $data['lname']; $pass = $password; $url = 'http://www.santulan.co.in/registration/verification/' . $gvfcode; $message = "dear $firstname $lastname, \n " . '<p dir="ltr" style="color: rgb(34, 34, 34); font-family:tahoma, tahoma; font-size: 14 background-color: rgb(255, 255, 255);"> thank reaching out santulan. please activate account clicking on below link.</p> <p dir="ltr" style="color: rgb(34, 34, 34); font-family: tahoma, tahoma; background-color: rgb(255, 255, 255);"> <!---<strong>you can take counselling via phone or face 2 face</strong></p>---> <p dir="ltr" style="color: rgb(34, 34, 34); font-family: tahoma, tahoma; background-color: rgb(255, 255, 255);"> <!---<strong>for more details contact or helpline no.</p>---> <p dir="ltr" style="color: rgb(34, 34, 34); font-family: tahoma, tahoma; background-color: rgb(255, 255, 255);"> <!---<strong>also can activate account clicking below link</p>---> <p dir="ltr" style="color: rgb(34, 34, 34); font-family: tahoma, tahoma; fon background-color: rgb(255, 255, 255);"> <a href="' . $url .'"><b>' . $url .'</b></a></p> <p dir="ltr" style="color: rgb(34, 34, 34); font-family: tahoma, tahoma; background-color: rgb(255, 255, 255);"> login id email address : ' . $email . '</p> <p dir="ltr" style="color: rgb(34, 34, 34); font-family: tahoma, tahoma; background-color: rgb(255, 255, 255);"> password : ' . $pass . '</p> <p dir="ltr" style="color: rgb(34, 34, 34); font-family: tahoma, tahoma; background-color: rgb(255, 255, 255);"> <em>thank you,<br /> team santulan </em></p>'; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to(trim($email)); $this->email->subject('registration confirmation'); $this->email->message($message); $this->email->send(); } /** function send email form submitted mail e-counseling **/ public function send_mail_to_user($email) { $base_url = base_url(); $this->email->initialize($this->config); $message_str = '<p> hello there'. '<br>'. '<br>we have received request. in touch shortly'. '<br>'. '<br>team santulan </p>'; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject('message santulan: filled form e-counseling'); $this->email->message($message_str); $this->email->send(); } /** function send email form submitted mail telephonic-counseling **/ public function send_mail_to_tele_user($email) { $base_url = base_url(); $this->email->initialize($this->config); $message_str = '<p> hello there'. '<br>'. '<br>we have received request. in touch shortly'. '<br>'. '<br>team santulan </p>'; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject('message santulan: counseling appointment'); $this->email->message($message_str); $this->email->send(); } /** function send email form submitted mail f f-counseling **/ public function send_mail_to_ftof_user($email) { $base_url = base_url(); $this->email->initialize($this->config); $message_str = '<p> hello there'. '<br>we have received request. in touch shortly'. '<br>'. '<br>team santulan </p>'; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject('message santulan: counseling appointment'); $this->email->message($message_str); $this->email->send(); } /** function send email form submitted mail video - counseling **/ public function send_mail_to_video_user($email) { $base_url = base_url(); $this->email->initialize($this->config); $message_str ='<p> hello there'. '<br>'. '<br>we have received request. in touch shortly'. '<br>'. '<br>team santulan </p>'; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject('message santulan: counseling appointment'); $this->email->message($message_str); $this->email->send(); } /** public function send_mail_fs() { $userid = $this->session->all_userdata(); $email = $userid['logged_in']['email']; $base_url = base_url(); $this->email->initialize($this->config); $message_str = '<p>hello there,<br> have new case assignment,please login , assighn counselor. </p>'; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject("this first support mail"); $this->email->message($message_str); $this->email->send(); } **/ public function send_counselor_mail($email) { $this->email->initialize($this->config); $message_str = 'hello mail counselor testing'; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to("hemantrandivehr@gmail.com"); $this->email->subject("this first support mail"); $this->email->message($message_str); $this->email->send(); } /** function send mail enduser thatb session closed **/ public function send_session_close_mail($session_id,$c_type,$cid) { //$url = 'https://www.surveymonkey.com/r/?sm=s8ma655vb3jd39qmanl2ypavwsbl3xphrbw6ryebhkgrubuq8slynsx3hy6gwgopkuijdbqy0gri%2fpd77ydwosp4r%2foxahlr52uarcumilg%3d'; if($c_type=='e_counseling') { $qry="select email end_employee_master id=(select eemp_id book_e_counseling_mst caseid='ec-".$cid."')" ; $query=$this->db->query($qry); $num=$query->num_rows(); foreach($query->result() $row) { $email=$row->email; } $this->email->initialize($this->config); $message_str = 'your session '.$c_type.'is closed,your case id '.$cid.' please click on link <a href="https://www.surveymonkey.com/r/nnlk2r2">click here</a> '; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject("this mail counselor"); $this->email->message($message_str); $this->email->send(); } if($c_type=='telephone_counseling') { $qry="select email book_tele_counseling_mstr caseid 'tc-" . $cid . "'"; $query=$this->db->query($qry); $num=$query->num_rows(); foreach($query->result() $row) { //$eemp_id=$row->eemp_id; $email=$row->email; } $this->email->initialize($this->config); $message_str = 'your session for'.$c_type.'is closed,your case id '.$cid.' please click on link <a href="https://www.surveymonkey.com/r/nnlk2r2">click here</a> '; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject("this mail counselor"); $this->email->message($message_str); $this->email->send(); } if($c_type=='f2f_counseling') { $qry="select email book_ff_counseling_mstr caseid 'fc-" . $cid . "'"; $query=$this->db->query($qry); $num=$query->num_rows(); foreach($query->result() $row) { //$eemp_id=$row->eemp_id; $email=$row->email; } $this->email->initialize($this->config); $message_str = 'your session for'.$c_type.'is closed,your case id '.$cid.' please click on link <a href="https://www.surveymonkey.com/r/nnlk2r2">click here</a> '; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject("this mail counselor"); $this->email->message($message_str); $this->email->send(); } if($c_type=='video_counseling') { $qry="select email book_vedio_counseling_mstr caseid 'vc-" . $cid . "'"; $query=$this->db->query($qry); $num=$query->num_rows(); foreach($query->result() $row) { //$eemp_id=$row->eemp_id; $email=$row->email; } $this->email->initialize($this->config); $message_str = 'your session for'.$c_type.'is closed,your case id '.$cid.' please click on link <a href="https://www.surveymonkey.com/r/nnlk2r2">click here</a> '; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject("this mail counselor"); $this->email->message($message_str); $this->email->send(); } } }
as per comment 339 , 340 line number showing error,its email variable there in send_session_close_mail()
next code :
foreach($query->result() $row) { $email=$row->email; } $this->email->initialize($this->config); $message_str = 'your session '.$c_type.'is closed,your case id '.$cid.' please click on link <a href="https://www.surveymonkey.com/r/nnlk2r2">click here</a> '; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject("this mail counselor"); $this->email->message($message_str); $this->email->send();
i come know want send email multiple email-ids have foreach
loop. , in loop
variable email declared.
i suggest put sendding email code in loop
follow , try once
foreach($query->result() $row) { $email=$row->email; $this->email->initialize($this->config); $message_str = 'your session '.$c_type.'is closed,your case id '.$cid.' please click on link <a href="https://www.surveymonkey.com/r/nnlk2r2">click here</a> '; $this->email->from('no.reply@santulan.co.in', 'santulan suport team'); $this->email->to($email); $this->email->subject("this mail counselor"); $this->email->message($message_str); $this->email->send(); }
this may solve issue.
Comments
Post a Comment