Advertisement
Guest User

send_email

a guest
Mar 22nd, 2016
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('BASEPATH'))exit('No direct script access allowed');
  4.  
  5. class KirimEmail extends CI_Controller {
  6.  
  7.     public function __construct() {
  8.         parent::__construct();
  9.         $this->load->helper('form');
  10.         $this->load->library('form_validation');
  11.         $this->load->library('encrypt');
  12.     }
  13.    
  14.     // Send Gmail to another user
  15.     public function index() {
  16.  
  17.         $sender_email = "rizalubuntuuser@gmail.com";
  18.         $user_password = "rahasiaqu";
  19.         $receiver_email = "rizalubuntuuser@gmail.com";
  20.         $username = 'Rizal';
  21.         $subject = 'tes kirim email';
  22.         $message = '<b>tes kirim email dari ane</b>';
  23.        
  24.         $config['protocol'] = 'smtp';
  25.         $config['smtp_host'] = 'ssl://smtp.googlemail.com';
  26.         $config['smtp_port'] = 465;
  27.         $config['smtp_user'] = $sender_email;
  28.         $config['smtp_pass'] = $user_password;
  29.             // Load email library and passing configured values to email library
  30.         $this->load->library('email', $config);
  31.         $this->email->set_newline("\r\n");
  32.             // Sender email address
  33.         $this->email->from($sender_email, $username);
  34.         // Receiver email address
  35.         $this->email->to($receiver_email);
  36.         // Subject of email
  37.         $this->email->subject($subject);
  38.         // Message in email
  39.         $this->email->message($message);
  40.  
  41.         if ($this->email->send()) {
  42.             echo 'Email Successfully Send !';
  43.         } else {
  44.             echo '<p class="error_msg">Invalid Gmail Account or Password !</p>';
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement