Mail is read or not read notification


Project Structure

index.php

<?php
$to  = '*********@gmail.com';
$subject = 'Read Mail';
$cdRand = md5(date('Y-M-d H:i:s'));
$img = 'http://www.domainname.com/imagepage.php?id=1&cd='.$cdRand;
$message = 'Testing Data <img src="'.$img.'">';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$mail = mail($to, $subject, $message,$headers);
if($mail){
echo 'Mail has been send';
} else {
echo 'Not Send Mail';
}

?>

imagepage.php

<?php 
$db=mysql_connect('localhost','root','');
mysql_select_db('database_name',$db);
if(!empty($_GET['id'])){
$id = $_GET['id'];
$sql = "update tbl_mail set read_flg=1 where id =".$id;
$rs = mysql_query($sql,$db);
$file_path = "images/trans.png";
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Content-type: image/png");
ob_clean();
flush();
readfile($file_path);    
}

?>

query.sql

CREATE TABLE `tbl_mail` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mail_body` varchar(100) DEFAULT NULL,
  `read_flg` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
Share on Google Plus

About Ram Pukar

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

0 comments:

Post a Comment