Friday, September 21, 2018

How to check whether email is read by user using PHP[SOLVED]

Below is the complete code using in php for sending email and read the status if use has opened the mail or not
call the function 
function sendEamil(201, 'bikash ranjan', 'harihar@gmail.com','Harihar','Nayak');
Declared below function to send the email
function sendEamil($id='', $to_name='', $to_address='',$firstName,$lastName){
    $from_name     = 'Bikash ranjan nayak';
    $from_address  = 'nayak.bikash@gmail.com';
    $reply_address  = 'no-reply@gmail.com';    
    $bccEmail    = 'nayak.bikash@yahoo.com';
    $contact_name  = $firstName." ".$lastName;   
    //set hidden url for captured the read mail
    $hiddenUrl      = 'http:127.0.0.1/readmail/readmail.php?type=table&id='.$id;
    
   $maildescription ='<!doctype html>
 <html>
 <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>php technical group</title>
   
 </head>';
  $contentBOdy.= 'Body HTML contents';  
  
  $maildescription.= '<body bgcolor="#ffffff" width="100%" style="margin: 0;" yahoo="yahoo">
    '.$contentBOdy.'
   
    <div style="display:none">
        <img alt="" src="'.$hiddenUrl.'" width="0px" height="0px" />
    </div>
</body>

</html>';
    
// Mail Description ( HTML ) End here
    // Mail Header
    $subject  = "Register form";
    $mime_boundary = "----PHP technical Register form ----".MD5(TIME().$id.TIME());
    $headers  = "MIME-Version: 1.0\n";
    $headers .= "Date:".date('r', $_SERVER['REQUEST_TIME'])."\n";
    $headers .= "Message-ID:<" . $_SERVER['REQUEST_TIME'] . md5($_SERVER['REQUEST_TIME']) .$id. "@" . $_SERVER['SERVER_NAME'] . ">\n";
    $headers .= "From:".$from_name."<".$from_address.">\n";
    $headers .= "Bcc:".$bccEmail." \n";
    $headers .= "Reply-To:".$from_name."<".$reply_address.">\n";
    $headers .= "Return-Path:".$from_name."<".$reply_address.">\n";
    $headers .= "X-Mailer: PHP v".phpversion()."\n";
    $headers .= "X-Originating-IP:".$_SERVER['SERVER_ADDR']."\n";
    $headers .= "X-MessageID:".$id."\n";
    $headers .= "X-ListMember:".$to_address."\n";
    $headers .= "Precedence: bulk\n";
    $headers .= "Bounces-To: ".$reply_address."\n";
    $headers .= "List-Unsubscribe: <https://phptechnicalgroups.blogspot.com>\n";
    $headers .= "List-Owner: <mailto:".$from_address.">\n";
    $headers .= "X-Feedback-ID:"."2016:".$id.":event:register\n";
    $headers .= "Content-Type: multipart/mixed; boundary=\"$mime_boundary\"\n";
    $setReturnPath = "<webmaster@phptechncalgrop.com>";
    $additional = "-f".$setReturnPath;

    //Create Email Body (HTML)
    $message = "--$mime_boundary\n";
    $message .= "Content-Type: text/html; charset=UTF-8\n";
    $message .= "Content-Transfer-Encoding: 8bit\n\n";
    $message .= "<html>\n";
    $message .= "<body>\n";
    $message .= $maildescription;
    $message .= "</body>\n";
    $message .= "</html>\n";
    $message .= "--$mime_boundary\n";
    $message .= "Content-Transfer-Encoding: base64\n";
    $mailsent = mail($to_address, $subject, $message, $headers,$additional);
    return ($mailsent)?(true):(false);
  }

2 comments:

  1. Started out in 2012, Data Science Central is one of the industry’s leading and fastest growing Internet
    community for data practitioners. Whether it is data science or machine learning or deep learning or
    big data, Data Science Central is a one-stop shop that covers a wide range of data science topics that
    includes technology, tools, data visualisation, code, and job opportunities. Also, many industry experts
    contribute to the community forum for discussion or questions.

    DATASCIENCETraining in OMR Chennai

    ReplyDelete
  2. Namun umumnya capsa susun lebih dikenal dengan nama Russian Poker. Dalam situs judi online, capsa dikenal dalam dua bentuk permainan. Yang pertama dikenal dengan sebutan capsa banting dan yang kedua
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme terbaik
    hobiqq
    paito warna
    bocoran sgp
    data hk

    ReplyDelete