Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- /**
- *
- */
- class Email extends CI_Controller{
- function __construct(){
- parent::__construct();
- $this->load->library('MyPHPMailer'); // load library
- require 'php_mailer/PHPMailerAutoload.php';
- }
- function kirim_pesan($email, $subject, $pesan)
- {
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPDebug = 0;
- $mail->SMTPAuth = true;
- $mail->Host = "smtp.gmail.com"; //smtp gmail
- $mail->From = "alexandertommy10@gmail.com"; //alamat email asal
- $mail->Port = 587; //tcp post
- $mail->AddAddress($email); //alamat email penerima
- $mail->Username = "alexandertommy10@gmail.com"; //username atau email smtp yang anda miliki
- $mail->Password = "15 komentar"; // password smtp yang anda miliki
- $mail->SetFrom('alexandertommy10@gmail.com', 'Tom');
- $mail->AddReplyTo('alexandertommy10@gmail.com', 'Toms');
- $mail->Subject = $subject; //subjek email anda
- $mail->Body = $pesan; //isi pesan email anda
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- $mail->isHTML(true);
- $mail->Send();
- }
- if (isset($_POST['nama']) && isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['pesan'])) {
- $nama = $_POST['nama'];
- $email = $_POST['email'];
- $subject = $_POST['subject'];
- $pesan = $_POST['pesan'];
- if (kirim_pesan($email, $subject, $pesan)) {
- echo "Pesan Berhasil Terkirim";
- } else {
- echo "Email Gagal Terkirim";
- }
- } else {
- exit();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement