Codeigniter provides many built in helpers and libraries which help us to perform lot of functionality for developing projects. Here a simple email library make us able to send email using our Gmail account living in CI environment.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
<!--? class Send_Email extends Controller { function Send_Email() { parent::Controller(); } function index() { $config = Array( 'protocol' =--> 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'email_address@gmail.com', // change it to yours 'smtp_pass' => 'your_password', // change it to yours 'mailtype' => 'html', 'charset' => 'iso-8859-1', 'wordwrap' => TRUE ); $this->load->library('email', $config); $this->email->set_newline("\r\n"); $this->email->from('your_email@domain.com'); // change it to yours $this->email->to('your_email@domain.com'); // change it to yours $this->email->subject('Email using Gmail.'); $this->email->message('Working fine ! !'); if($this->email->send()) { echo 'Email sent.'; } else { show_error($this->email->print_debugger()); } } }?> |
Comments are closed.