Email Tracker

Email Tracker

Email Tracker : -  In this post You learn how to track if email is opened by user or not ,this is best script for promotional  email marketing time to time u update how many user open our email.

This is vary easy to use you only add img tag with query string in src in your massege body,when user open email querystring hit your server nad you update your status of send mail by email and unique id.

create database phpcooker_script

and export this



--
-- Database: `poiuy_script`
--

-- --------------------------------------------------------

--
-- Table structure for table `emailtracker`
--

CREATE TABLE IF NOT EXISTS `emailtracker` (
  `tracker_id` int(10) NOT NULL AUTO_INCREMENT,
  `tracker_email` varchar(120) NOT NULL,
  `tracker_uid` varchar(60) NOT NULL,
  `tracker_status` enum('0','1') NOT NULL,
  PRIMARY KEY (`tracker_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

--
-- Dumping data for table `emailtracker`
--

INSERT INTO `emailtracker` (`tracker_id`, `tracker_email`, `tracker_uid`, `tracker_status`) VALUES
(1, 'info@phpcooker.com', '599a80cb057a1', '1'),
(2, 'info@phpcooker.com', '599a81faa89f7', '0'),
(3, 'info@phpcooker.com', '599a82040d076', '0');

 

 

create index.php  use this code



<?php
include"tracker.php";
if(isset($_POST['send'])){
$to = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
if(filter_var($to, FILTER_VALIDATE_EMAIL)) {
$uid = uniqid();
date_default_timezone_set('UTC');
include"phpmailer/class.phpmailer.php";
include"phpmailer/class.pop3.php";
include"phpmailer/class.smtp.php";
$subject = 'Hi this email tracker example mail by PHP Cooker';
$body = "Hi this example mail body of how to track email is open or not in php";
$body .= "<img border='0' src='http://yourdomen.com/tracker.php?email=$to&uid=$uid' width='1' height='1' alt='mail' >";
       

$mail = new PHPMailer;
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 3;

$mail->IsSMTP();
$mail->Host = 'mail.yourdomen.com';
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = 'yoyrwebmailid';     // SMTP server username
$mail->Password = 'password';            // SMTP server password

$mail->Debugoutput = 'html';
$mail->IsHTML(true);
$mail->From     = 'info@phpcooker.com';
$mail->FromName = "PHP Cooker";
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->MsgHTML($body);

if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
     $query ="insert into emailtracker(tracker_email,tracker_uid) values('$to','$uid')";
     mysql_query($query,$conn) or die("failed".mysql_error());
}

 


}else{
$msg="Email is not valid";
}
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Email tracker in php</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
 
     <div class="container">    
     <h1>Email tracker in php</h1>
        <div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
            <div class="panel panel-info" >
                    <div class="panel-heading">
                    <div style="color:red" ><?php echo @$msg; ?></div>
                        <div class="panel-title">Send email </div>
                    </div>     

                    <div style="padding-top:30px" class="panel-body" >

                        <div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
                            
                        <form id="loginform" class="form-horizontal" role="form" method="post" >
                                    
                            <div style="margin-bottom: 25px" class="input-group">
                                        <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                                        <input id="login-username" type="email" class="form-control" name="email" value="" placeholder="example@example.com">                                        
                                    </div>
                              
                                
                            <div class="input-group">
                                <div style="margin-top:10px" class="form-group">
                                    <!-- Button -->

                                    <div class="col-sm-12 controls">
                                      <button id="btn-login" value="submit" type="submit" name="send" class="btn btn-success">Send</a>
                                    
                                  </div>
                                </div>


                              
                            </form>     

 

                        </div>                     
            </div>  
        </div>
        
        
        <table class="table">
    <thead>
      <tr>
      <th>title</th>
      <th>Id</th>
      <th>Status</th>
      </tr>
    </thead>
    <tbody>
    <?php
$query = "select * from emailtracker";                   
$rs = mysql_query($query,$conn) or die("Error : ".mysql_error());
while($data = mysql_fetch_assoc($rs)){
    ?>
      <tr>
      <td><?php echo $data["tracker_email"]; ?></td>
      <td><?php echo $data["tracker_uid"]; ?></td>
      <td><?php if( $data["tracker_status"]=='1'){ echo"<font color='green' >Opend</font>"; }else{ echo"<font color='red' >not open</font>"; }  ?></td>
      </tr>
      <?php     
}
    

?>
    </tbody>
  </table>
     </div>

</body>
</html>

 

create tracker.php and use this code


<?php
$conn  = @mysql_connect("localhost","root","");
mysql_select_db("phpcooker_script",$conn);
if(isset($_REQUEST['uid']))
{
$uid   =$_REQUEST['uid'];
$email =$_REQUEST['email'];
$query ="update emailtracker set tracker_status ='1' where tracker_email='$email' and tracker_uid ='$uid'";
mysql_query($query,$conn) or die("failed".mysql_error());
}
?>

smileysmileysmileysmileysmiley

Download Here

Total Coments (0)