I am sharing this post which explains how to send HTML Template as an email using SMTP and PHPMailer in codeigniter.
Create a html template as per the requirement send this html page as per the project requirment.
Now we learn how to send Email by PHPMailer and Gmail Codeigniter.
Step:1
First Create a HTML Template welcumemail.php Page which is suitable for your requirement.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Codeigniter</title>
</head>
<body>
<div class="wrapper">
<div style="margin:auto; text-align:center; width:625px;">
<p >Update your profile
Welcome Mail</p>
<p>Welcome to Codeigniter EmaIL!<br/></p>
</div>
</div>
</body>
</html>
Step:2
Create Controller Method for sending email.
public function sendemail()
{
$data = array();
$this->load->library('email');
$subject='Welcome to Codeigniter';
$htmlContent = echo $this->load->view('welcumemail');
$config['mailtype'] = 'html';
$this->load->library('email');
require("assets/testing/class.phpmailer.php");
$email1='d.mehra@gmail.com';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "xyz.in";
$mail->SMTPAuth = true;
//$mail->SMTPSecure = "ssl";
$mail->Port = 587;
$mail->Username = "contact@xyz.in";
$mail->Password = "xyz";
$mail->From = "contact@xyz.in";
$mail->FromName = "ABC";
$mail->AddAddress("$email1");
$mail->IsHTML(true);
$mail->Subject = "Welcome ...";
$mail->Body = ($htmlContent);
$mail->Send();
return True;
}
Step:2
Create Controller Method for sending email.
public function sendemail()
{
$data = array();
$this->load->library('email');
$subject='Welcome to Codeigniter';
$htmlContent = echo $this->load->view('welcumemail');
$config['mailtype'] = 'html';
$this->load->library('email');
require("assets/testing/class.phpmailer.php");
$email1='d.mehra@gmail.com';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "xyz.in";
$mail->SMTPAuth = true;
//$mail->SMTPSecure = "ssl";
$mail->Port = 587;
$mail->Username = "contact@xyz.in";
$mail->Password = "xyz";
$mail->From = "contact@xyz.in";
$mail->FromName = "ABC";
$mail->AddAddress("$email1");
$mail->IsHTML(true);
$mail->Subject = "Welcome ...";
$mail->Body = ($htmlContent);
$mail->Send();
return True;
}
Just Replace Your email ids,username,password and sending email using codeigniter.
No comments:
Post a Comment