Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Mail_notif extends CI_Controller {
- public function __construct()
- {
- parent::__construct();
- date_default_timezone_set('Asia/Jakarta');
- $this->load->model('m_mail_notif', 'notif');
- $this->load->helper('url');
- }
- public function tombol_buka($nokey){
- $tgl_wkt = date('Y-m-d H:i:s');
- $data = array(
- 'no_key' => $nokey,
- 'date' => $tgl_wkt,
- 'output_sensor' => 'buka'
- );
- if($this->db->insert('pintu_air', $data))
- {
- echo 'PINTU AIR SUKSES DIBUKA..';
- }
- }
- public function kirim($no_key)
- {
- $data_arr = array();
- $query = $this->notif->get_mail($no_key);
- foreach ($query->result() as $row)
- {
- $data_arr['nam'] = $row->nama;
- $data_arr['ema'] = $row->email;
- $data_arr['out'] = $row->output_sensor;
- }
- //$url = 'http://192.168.1.5/petaniku/mail_notif/tombol-buka/1';
- $subjek = 'KETINGGIAN PERMUKAAN AIR PARIT';
- $pesan = '<H3>Hai '.$data_arr['nam'].', Kondisi Air Sedang Tingi, Silahkan buka PINTU AIR !</H3>
- <div style="margin-top: 40px; margin-bottom:20px; font-size: 25px; color: red;">
- KETINGGIAN AIR = '.$data_arr['out'].' cm
- </div>
- <br/><br/>Silahkan buka aplikasi untuk menutupnya, atau bisa juga dengan menekan tombol BUKA dibawah.<br/><br/>
- <form action="https://ferrynurr.com/mail_notif/tombol_buka/1" method="get" enctype="multipart/form-data">
- <button type="submit" form="form1" value="Submit">BUKA</button>
- </form>
- <br/><br/>
- Pesan dikirim dari alat, jangan di balas... Terimaksih..!';
- $config = Array(
- 'protocol' => 'smtp',
- 'smtp_host' => 'mail.ferrynurr.com',
- 'smtp_port' => 465,
- 'smtp_user' => 'petanibawang@ferrynurr.com', //isi dengan emailmu!
- 'smtp_pass' => 'pasword_sensor_di_ya', //isi dengan password emailmu!
- 'mailtype' => 'html',
- 'charset' => 'utf-8',
- 'newline' => '\r\n',
- 'wordwrap' => TRUE
- );
- $this->load->library('email', $config);
- // $this->email->set_newline("\r\n");
- $this->email->from('petanibawang@ferrynurr.com', 'SMART AGRICULTURE BAWANG MERAH');
- $this->email->to($data_arr['ema']); //email tujuan. Isikan dengan emailmu!
- $this->email->subject($subjek);
- $this->email->message($pesan);
- if($this->email->send())
- {
- echo 'Email sent...';
- }
- else
- {
- show_error($this->email->print_debugger());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement