Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Mail2 extends CI_Controller {
- public function __construct() {
- parent::__construct();
- require_once(APPPATH.'libraries/PHPMailerAutoload.php');
- require_once(APPPATH.'libraries/class.phpmailer.php');
- require_once(APPPATH.'libraries/class.smtp.php');
- }
- public function index() {
- $mail = new PHPMailer();
- $mail->IsSMTP(); // we are going to use SMTP
- $mail->SMTPAuth = true; // enabled SMTP authentication
- $mail->SMTPSecure = "ssl"; // prefix for secure protocol to connect to the server
- $mail->Host = "smtp.gmail.com"; // setting GMail as our SMTP server
- $mail->Port = 465; // SMTP port to connect to GMail
- $mail->Username = "dyazincahya.cd@gmail.com"; // user email address
- $mail->Password = "***"; // password in GMail
- $mail->SetFrom('dyazincahya.cd@gmail.com', 'DYAZ OX'); //Who is sending the email
- $mail->AddReplyTo("dyazincahya@gmail.com","Cahya Dy"); //email address that receives the response
- $mail->Subject = "tester mail";
- $mail->Body = "<h1>Hallo</h1>";
- $mail->AltBody = "coba coba";
- $destino = "cobamasuk80@gmail.com"; // Who is addressed the email to
- $mail->AddAddress($destino, "hanny");
- $mail->AddAttachment(""); // some attached files
- $mail->AddAttachment(""); // as many as you want
- if(!$mail->Send()) {
- $data["message"] = "Error: " . $mail->ErrorInfo;
- } else {
- $data["message"] = "Message sent correctly!";
- }
- $this->load->view('sent_mail.php',$data);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement