Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. $ci = get_instance();
  2. $ci->load->library('email');
  3. $config['protocol'] = "smtp";
  4. $config['smtp_host'] = "ssl://smtp.gmail.com";
  5. $config['smtp_port'] = "465";
  6. $config['smtp_user'] = "test@gmail.com";
  7. $config['smtp_pass'] = "test";
  8. $config['charset'] = "utf-8";
  9. $config['mailtype'] = "html";
  10. $config['newline'] = "rn";
  11.  
  12. $ci->email->initialize($config);
  13.  
  14. $ci->email->from('test@test.com', 'Test Email');
  15. $list = array('test2@gmail.com');
  16. $ci->email->to($list);
  17. $this->email->reply_to('my-email@gmail.com', 'Explendid Videos');
  18. $ci->email->subject('This is an email test');
  19. $ci->email->message('It is working. Great!');
  20.  
  21. $ci->email->attach( '/test/myfile.pdf');
  22. $ci->email->send();
  23.  
  24. public function setemail()
  25. {
  26. $email="xyz@gmail.com";
  27. $subject="some text";
  28. $message="some text";
  29. $this->sendEmail($email,$subject,$message);
  30. }
  31. public function sendEmail($email,$subject,$message)
  32. {
  33.  
  34. $config = Array(
  35. 'protocol' => 'smtp',
  36. 'smtp_host' => 'ssl://smtp.googlemail.com',
  37. 'smtp_port' => 465,
  38. 'smtp_user' => 'abc@gmail.com',
  39. 'smtp_pass' => 'passwrd',
  40. 'mailtype' => 'html',
  41. 'charset' => 'iso-8859-1',
  42. 'wordwrap' => TRUE
  43. );
  44.  
  45.  
  46. $this->load->library('email', $config);
  47. $this->email->set_newline("rn");
  48. $this->email->from('abc@gmail.com');
  49. $this->email->to($email);
  50. $this->email->subject($subject);
  51. $this->email->message($message);
  52. $this->email->attach('C:UsersxyzDesktopimagesabc.png');
  53. if($this->email->send())
  54. {
  55. echo 'Email send.';
  56. }
  57. else
  58. {
  59. show_error($this->email->print_debugger());
  60. }
  61.  
  62. }
  63.  
  64. $ci->email->attach('d:/www/website/test/myfile.pdf');
  65.  
  66. Content-Type: application/pdf; name="test.pdf"<br>
  67. Content-Disposition: attachment;<br>
  68. Content-Transfer-Encoding: base64<br>
  69. JVBERi0xLjYNJeLjz9MNCjQzNyAwIG9iag08PC9MaW5lYXJpemVkIDEvTCA3OTUyMTYvTyA0Mzkv<br>
  70. RSA2ODEwODcvTiA0L1QgNzk0ODA3L0ggWyA1NjQgMjYxXT4+DWVuZG9iag0gICAgICAgICAgICAg<br>
  71.  
  72. Content-Type: application/pdf; name="test.pdf"<br>
  73. Content-Disposition: attachment;<br>
  74. Content-Transfer-Encoding: base64<br>
  75. <br>
  76. JVBERi0xLjYNJeLjz9MNCjQzNyAwIG9iag08PC9MaW5lYXJpemVkIDEvTCA3OTUyMTYvTyA0Mzkv<br>
  77. RSA2ODEwODcvTiA0L1QgNzk0ODA3L0ggWyA1NjQgMjYxXT4+DWVuZG9iag0gICAgICAgICAgICAg<br>
  78.  
  79. 'content' => chunk_split(base64_encode($file_content)),<br>
  80.  
  81. 'content' => "rn" . chunk_split(base64_encode($file_content)),<br>
  82.  
  83. <?php
  84.  
  85. class Email extends CI_Controller
  86. {
  87. public Function index();
  88. {
  89. $config = Array(
  90. 'protocol' => 'smtp',
  91. 'smpt_host' => 'ssl://googlemail.com',
  92. 'smtp_port' => 465,
  93. 'smtp_user' => 'example@gmail.com',
  94. 'smtp_pass' => 'yourpass'
  95. );
  96. $this->load->library('email', $config);
  97. $this->email->set_newline("rn");
  98.  
  99. $this->email->from('example@gmail.com');
  100. $this->email->to('example@gmail.com');
  101. $this->email->subject('This is a test email sending');
  102. $this->email->message('This is some message, you can type your own');
  103.  
  104. if($this->email->send()
  105. {
  106. echo "Your email has been sent";
  107. }else{
  108. show_error($this->email->print_debugger());
  109. }
  110.  
  111. }
  112.  
  113.  
  114. ?>
  115.  
  116. $this->load->helper('path');
  117. $path = set_realpath('./images/');
  118.  
  119. $this->email->attach($path . $your_file);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement