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;
- class Emailkedua extends CI_Controller {
- function __construct(){
- parent::__construct();
- $this->load->library('Phpmailer_lib'); // load library
- }
- public function index()
- {
- //require 'vendor/autoload.php';
- $mail = new PHPMailer(true); // Passing `true` enables exceptions
- try {
- //Server settings
- $mail->SMTPDebug = 2; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'ssl://smtp.gmail.com:465'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'mfathony115@gmail.com'; // SMTP username
- $mail->Password = '24041995muhammad'; // SMTP password
- //$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- //$mail->Port = 587; // TCP port to connect to
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- //Recipients
- $mail->setFrom('mfathony115@gmail.com');
- $mail->addAddress('backupmfathony@gmail.com', 'Muhammad Fathony'); // Add a recipient
- //$mail->addAddress('mfathony115@gmail.com'); // Name is optional
- $mail->addReplyTo('mfathony115@gmail.com', 'Information');
- // $mail->addCC('cc@example.com');
- // $mail->addBCC('bcc@example.com');
- //Attachments
- //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
- //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
- //Content
- //$headers = "MIME-Version: 1.0rn";
- //$headers .= "Content-type: text/html; charset=iso-8859-1rn";
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'Dari Toni';
- $mail->Body = $this->load->view('Email', '', TRUE);
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
- }
- }
- /* End of file Emailkedua.php */
- /* Location: ./application/controllers/conten_admin/Emailkedua.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement