Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Email()
- {
- parent::Controller();
- $this->load->library('email');
- }
- function index()
- {
- $config['protocol'] = 'smtp';
- $config['smtp_host'] = 'ssl://smtp.gmail.com';
- $config['smtp_port'] = '465';
- $config['smtp_timeout'] = '7';
- $config['smtp_user'] = 'mygmail@gmail.com';
- $config['smtp_pass'] = '*******';
- $config['charset'] = 'utf-8';
- $config['newline'] = "rn";
- $config['mailtype'] = 'text'; // or html
- $config['validation'] = TRUE; // bool whether to validate email or not
- $this->email->initialize($config);
- $this->email->from('mygmail@gmail.com', 'myname');
- $this->email->to('target@gmail.com');
- $this->email->subject('Email Test');
- $this->email->message('Testing the email class.');
- $this->email->send();
- echo $this->email->print_debugger();
- $this->load->view('email_view');
- }
- $config = Array(
- 'protocol' => 'smtp',
- 'smtp_host' => 'ssl://smtp.googlemail.com',
- 'smtp_port' => 465,
- 'smtp_user' => 'xxx',
- 'smtp_pass' => 'xxx',
- 'mailtype' => 'html',
- 'charset' => 'iso-8859-1'
- );
- $this->load->library('email', $config);
- $this->email->set_newline("rn");
- // Set to, from, message, etc.
- $result = $this->email->send();
- # alias to postfix in a typical Postfix server
- $config['protocol'] = 'sendmail';
- $config['mailpath'] = '/usr/sbin/sendmail';
- $this->load->library('email');
- $this->load->library('parser');
- $this->email->clear();
- $config['mailtype'] = "html";
- $this->email->initialize($config);
- $this->email->set_newline("rn");
- $this->email->from('email@example.com', 'Website');
- $list = array('chamil@archmage.lk', 'chamilsanjeewa@gmail.com');
- $this->email->to($list);
- $data = array();
- $htmlMessage = $this->parser->parse('messages/email', $data, true);
- $this->email->subject('This is an email test');
- $this->email->message($htmlMessage);
- if ($this->email->send()) {
- echo 'Your email was sent, thanks chamil.';
- } else {
- show_error($this->email->print_debugger());
- }
Add Comment
Please, Sign In to add comment