Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ci = get_instance();
- $ci->load->library('email');
- $config['protocol'] = "smtp";
- $config['smtp_host'] = "ssl://smtp.gmail.com";
- $config['smtp_port'] = "465";
- $config['smtp_user'] = "test@gmail.com";
- $config['smtp_pass'] = "test";
- $config['charset'] = "utf-8";
- $config['mailtype'] = "html";
- $config['newline'] = "rn";
- $ci->email->initialize($config);
- $ci->email->from('test@test.com', 'Test Email');
- $list = array('test2@gmail.com');
- $ci->email->to($list);
- $this->email->reply_to('my-email@gmail.com', 'Explendid Videos');
- $ci->email->subject('This is an email test');
- $ci->email->message('It is working. Great!');
- $ci->email->attach( '/test/myfile.pdf');
- $ci->email->send();
- public function setemail()
- {
- $email="xyz@gmail.com";
- $subject="some text";
- $message="some text";
- $this->sendEmail($email,$subject,$message);
- }
- public function sendEmail($email,$subject,$message)
- {
- $config = Array(
- 'protocol' => 'smtp',
- 'smtp_host' => 'ssl://smtp.googlemail.com',
- 'smtp_port' => 465,
- 'smtp_user' => 'abc@gmail.com',
- 'smtp_pass' => 'passwrd',
- 'mailtype' => 'html',
- 'charset' => 'iso-8859-1',
- 'wordwrap' => TRUE
- );
- $this->load->library('email', $config);
- $this->email->set_newline("rn");
- $this->email->from('abc@gmail.com');
- $this->email->to($email);
- $this->email->subject($subject);
- $this->email->message($message);
- $this->email->attach('C:UsersxyzDesktopimagesabc.png');
- if($this->email->send())
- {
- echo 'Email send.';
- }
- else
- {
- show_error($this->email->print_debugger());
- }
- }
- $ci->email->attach('d:/www/website/test/myfile.pdf');
- Content-Type: application/pdf; name="test.pdf"<br>
- Content-Disposition: attachment;<br>
- Content-Transfer-Encoding: base64<br>
- JVBERi0xLjYNJeLjz9MNCjQzNyAwIG9iag08PC9MaW5lYXJpemVkIDEvTCA3OTUyMTYvTyA0Mzkv<br>
- RSA2ODEwODcvTiA0L1QgNzk0ODA3L0ggWyA1NjQgMjYxXT4+DWVuZG9iag0gICAgICAgICAgICAg<br>
- Content-Type: application/pdf; name="test.pdf"<br>
- Content-Disposition: attachment;<br>
- Content-Transfer-Encoding: base64<br>
- <br>
- JVBERi0xLjYNJeLjz9MNCjQzNyAwIG9iag08PC9MaW5lYXJpemVkIDEvTCA3OTUyMTYvTyA0Mzkv<br>
- RSA2ODEwODcvTiA0L1QgNzk0ODA3L0ggWyA1NjQgMjYxXT4+DWVuZG9iag0gICAgICAgICAgICAg<br>
- 'content' => chunk_split(base64_encode($file_content)),<br>
- 'content' => "rn" . chunk_split(base64_encode($file_content)),<br>
- <?php
- class Email extends CI_Controller
- {
- public Function index();
- {
- $config = Array(
- 'protocol' => 'smtp',
- 'smpt_host' => 'ssl://googlemail.com',
- 'smtp_port' => 465,
- 'smtp_user' => 'example@gmail.com',
- 'smtp_pass' => 'yourpass'
- );
- $this->load->library('email', $config);
- $this->email->set_newline("rn");
- $this->email->from('example@gmail.com');
- $this->email->to('example@gmail.com');
- $this->email->subject('This is a test email sending');
- $this->email->message('This is some message, you can type your own');
- if($this->email->send()
- {
- echo "Your email has been sent";
- }else{
- show_error($this->email->print_debugger());
- }
- }
- ?>
- $this->load->helper('path');
- $path = set_realpath('./images/');
- $this->email->attach($path . $your_file);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement