Paste below code to send the email by SMTP in CodeIgniter controller.
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 |
function emailConfiguration() { $email = "info@gmail.com"; $this->load->library('email'); $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.gmail.com'; $config['smtp_port'] = '465'; $config['smtp_timeout'] = '7'; $config['smtp_user'] = $email; $config['smtp_pass'] = '1234567'; $config['charset'] = 'utf-8'; $config['newline'] = "\r\n"; $config['mailtype'] = 'html'; // or html $config['validation'] = TRUE; // bool whether to validate email or not $this->email->initialize($config); $this->email->from($email, 'Notification'); } function SendEmail() { $this->emailConfiguration(); $this->email->to("to@email.com"); $this->email->bcc('bcc@email.com'); $this->email->subject("Subject your email"); $this->email->message("Content of your email"); $this->email->send(); } |
More Stories
CPU & Memory usage in PHP
Install PHP mcrypt extension on Ubuntu
Text to speech