Guest User

Untitled

a guest
Apr 26th, 2018
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. function Email()
  2. {
  3. parent::Controller();
  4. $this->load->library('email');
  5. }
  6.  
  7. function index()
  8. {
  9. $config['protocol'] = 'smtp';
  10. $config['smtp_host'] = 'ssl://smtp.gmail.com';
  11. $config['smtp_port'] = '465';
  12. $config['smtp_timeout'] = '7';
  13. $config['smtp_user'] = 'mygmail@gmail.com';
  14. $config['smtp_pass'] = '*******';
  15. $config['charset'] = 'utf-8';
  16. $config['newline'] = "rn";
  17. $config['mailtype'] = 'text'; // or html
  18. $config['validation'] = TRUE; // bool whether to validate email or not
  19.  
  20. $this->email->initialize($config);
  21.  
  22.  
  23. $this->email->from('mygmail@gmail.com', 'myname');
  24. $this->email->to('target@gmail.com');
  25.  
  26. $this->email->subject('Email Test');
  27. $this->email->message('Testing the email class.');
  28.  
  29. $this->email->send();
  30.  
  31. echo $this->email->print_debugger();
  32.  
  33. $this->load->view('email_view');
  34.  
  35. }
  36.  
  37. $config = Array(
  38. 'protocol' => 'smtp',
  39. 'smtp_host' => 'ssl://smtp.googlemail.com',
  40. 'smtp_port' => 465,
  41. 'smtp_user' => 'xxx',
  42. 'smtp_pass' => 'xxx',
  43. 'mailtype' => 'html',
  44. 'charset' => 'iso-8859-1'
  45. );
  46. $this->load->library('email', $config);
  47. $this->email->set_newline("rn");
  48.  
  49. // Set to, from, message, etc.
  50.  
  51. $result = $this->email->send();
  52.  
  53. # alias to postfix in a typical Postfix server
  54. $config['protocol'] = 'sendmail';
  55. $config['mailpath'] = '/usr/sbin/sendmail';
  56.  
  57. $this->load->library('email');
  58. $this->load->library('parser');
  59.  
  60.  
  61.  
  62. $this->email->clear();
  63. $config['mailtype'] = "html";
  64. $this->email->initialize($config);
  65. $this->email->set_newline("rn");
  66. $this->email->from('email@example.com', 'Website');
  67. $list = array('chamil@archmage.lk', 'chamilsanjeewa@gmail.com');
  68. $this->email->to($list);
  69. $data = array();
  70. $htmlMessage = $this->parser->parse('messages/email', $data, true);
  71. $this->email->subject('This is an email test');
  72. $this->email->message($htmlMessage);
  73.  
  74.  
  75.  
  76. if ($this->email->send()) {
  77. echo 'Your email was sent, thanks chamil.';
  78. } else {
  79. show_error($this->email->print_debugger());
  80. }
Add Comment
Please, Sign In to add comment