Guest User

Untitled

a guest
Mar 3rd, 2018
650
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. $config = Array(
  2. 'protocol' => 'smtp',
  3. 'smtp_host' => 'ssl://smtp.google.com',
  4. 'smtp_port' => 465,
  5. 'smtp_user' => 'sender@gmail.com',
  6. 'smtp_pass' => 'password'
  7. );
  8.  
  9. $this->load->library('email',$config);
  10. $this->email->set_newline("rn");
  11.  
  12. $this->email->from("sender@gmail.com");
  13. $this->email->to("receiver@gmail.com");
  14. $this->email->subject("Email with Codeigniter");
  15. $this->email->message("This is email has been sent with Codeigniter");
  16.  
  17. if($this->email->send())
  18. {
  19. echo "Your email was sent.!";
  20. } else {
  21. show_error($this->email->print_debugger());
  22. }
  23.  
  24. public function send_mail()
  25. {
  26. require_once(APPPATH.'third_party/PHPMailer-master/PHPMailerAutoload.php');
  27. $mail = new PHPMailer();
  28. $mail->IsSMTP(); // we are going to use SMTP
  29. $mail->SMTPAuth = true; // enabled SMTP authentication
  30. $mail->SMTPSecure = "ssl"; // prefix for secure protocol to connect to the server
  31. $mail->Host = "smtp.gmail.com"; // setting GMail as our SMTP server
  32. $mail->Port = 465; // SMTP port to connect to GMail
  33. $mail->Username = "mail@gmail.com"; // user email address
  34. $mail->Password = "password"; // password in GMail
  35. $mail->SetFrom('mail@gmail.com', 'Mail'); //Who is sending
  36. $mail->isHTML(true);
  37. $mail->Subject = "Mail Subject";
  38. $mail->Body = '
  39. <html>
  40. <head>
  41. <title>Title</title>
  42. </head>
  43. <body>
  44. <h3>Heading</h3>
  45. <p>Message Body</p><br>
  46. <p>With Regards</p>
  47. <p>Your Name</p>
  48. </body>
  49. </html>
  50. ';
  51. $destino = receiver@gmail.com; // Who is addressed the email to
  52. $mail->AddAddress($destino, "Receiver");
  53. if(!$mail->Send()) {
  54. return false;
  55. } else {
  56. return true;
  57. }
  58. }
  59.  
  60. 'smtp_host' => 'ssl://smtp.googlemail.com',
Add Comment
Please, Sign In to add comment