Advertisement
Guest User

Untitled

a guest
Feb 12th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. use PHPMailer\PHPMailer\PHPMailer;
  4. class Emailkedua extends CI_Controller {
  5.  
  6.  
  7. function __construct(){
  8. parent::__construct();
  9. $this->load->library('Phpmailer_lib'); // load library
  10. }
  11.  
  12. public function index()
  13. {
  14. //require 'vendor/autoload.php';
  15. $mail = new PHPMailer(true); // Passing `true` enables exceptions
  16. try {
  17. //Server settings
  18. $mail->SMTPDebug = 2; // Enable verbose debug output
  19. $mail->isSMTP(); // Set mailer to use SMTP
  20. $mail->Host = 'ssl://smtp.gmail.com:465'; // Specify main and backup SMTP servers
  21. $mail->SMTPAuth = true; // Enable SMTP authentication
  22. $mail->Username = 'mfathony115@gmail.com'; // SMTP username
  23. $mail->Password = '24041995muhammad'; // SMTP password
  24. //$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  25. //$mail->Port = 587; // TCP port to connect to
  26. $mail->SMTPOptions = array(
  27. 'ssl' => array(
  28. 'verify_peer' => false,
  29. 'verify_peer_name' => false,
  30. 'allow_self_signed' => true
  31. )
  32. );
  33. //Recipients
  34. $mail->setFrom('mfathony115@gmail.com');
  35. $mail->addAddress('backupmfathony@gmail.com', 'Muhammad Fathony'); // Add a recipient
  36. //$mail->addAddress('mfathony115@gmail.com'); // Name is optional
  37. $mail->addReplyTo('mfathony115@gmail.com', 'Information');
  38. // $mail->addCC('cc@example.com');
  39. // $mail->addBCC('bcc@example.com');
  40.  
  41. //Attachments
  42. //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  43. //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
  44.  
  45. //Content
  46. //$headers = "MIME-Version: 1.0rn";
  47.  
  48. //$headers .= "Content-type: text/html; charset=iso-8859-1rn";
  49. $mail->isHTML(true); // Set email format to HTML
  50. $mail->Subject = 'Dari Toni';
  51. $mail->Body = $this->load->view('Email', '', TRUE);
  52. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  53.  
  54. $mail->send();
  55. echo 'Message has been sent';
  56. } catch (Exception $e) {
  57. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  58. }
  59. }
  60.  
  61. }
  62.  
  63. /* End of file Emailkedua.php */
  64. /* Location: ./application/controllers/conten_admin/Emailkedua.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement