Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- class Email extends CI_Controller {
- function __construct(){
- parent::__construct();
- $this->load->config('email');
- $this->load->library('Mymailer');
- // load library
- }
- public function index()
- {
- //Create a new PHPMailer instance
- $this->Mymailer = new PHPMailer;
- //Tell PHPMailer to use SMTP
- $this->Mymailer->isSMTP();
- //Enable SMTP debugging
- // 0 = off (for production use)
- // 1 = client messages
- // 2 = client and server messages
- $this->Mymailer->SMTPDebug = $this->config->item('SMTPDebug');
- //Set the hostname of the mail server
- $this->Mymailer->Host = "ssl://smtp.gmail.com:465";
- $this->Mymailer->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- //Set the SMTP port number - likely to be 25, 465 or 587
- //$this->Mymailer->Port = $this->config->item('Port');
- //Whether to use SMTP authentication
- $this->Mymailer->SMTPAuth = $this->config->item('SMTPAuth');
- //Username to use for SMTP authentication
- $this->Mymailer->Username = $this->config->item('Username');
- //Password to use for SMTP authentication
- $this->Mymailer->Password = $this->config->item('Password');
- //Set who the message is to be sent from
- $this->Mymailer->setFrom($this->config->item('Username'), $this->config->item('Name'));
- //Set an alternative reply-to address
- $this->Mymailer->addReplyTo($this->config->item('Username'), $this->config->item('Name'));
- //Set who the message is to be sent to
- $this->Mymailer->addAddress('mfathony115@gmail.com', 'John Doe');
- //Set the subject line
- $this->Mymailer->Subject = 'jajal email';
- //Read an HTML message body from an external file, convert referenced images to embedded,
- //convert HTML into a basic plain-text alternative body
- //$this->Mymailer->msgHTML("dari localhost <h1 class='ok'> dari </h1>");
- //$this->Mymailer->set_mailtype("html");
- $msg = "oookk";
- //$this->Mymailer->set_header('MIME-Version','1.0; charset=utf-8');
- //$this->Mymailer->set_header('Content-type','text/html');
- $this->Mymailer->isHTML(true);
- $this->Mymailer->Body = $msg;
- //Replace the plain text body with one created manually
- $this->Mymailer->AltBody = 'This is a plain-text message body';
- //Attach an image file
- //$this->Mymailer->addAttachment('images/phpmailer_mini.png');
- //send the message, check for errors
- if (!$this->Mymailer->send()) {
- echo 'Mailer Error: ' . $this->Mymailer->ErrorInfo;
- } else {
- echo 'Message sent!';
- }
- }
- function template_email(){
- $this->load->view('Email');
- }
- }
- /* End of file mail.php */
- /* Location: ./application/controllers/conten_admin/mail.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement