私は何百もの電子メールがユーザーによって送信される電子メール システム (PHP ベース) に取り組んでおり、それらの電子メールを追跡したいので、電子メールが開かれているかどうかを知ることができますか?
これを行う方法を教えてもらえますか?
ありがとう
私は何百もの電子メールがユーザーによって送信される電子メール システム (PHP ベース) に取り組んでおり、それらの電子メールを追跡したいので、電子メールが開かれているかどうかを知ることができますか?
これを行う方法を教えてもらえますか?
ありがとう
私が知っている唯一の方法は、あまり信頼できるものではありませんが、次のような内容を含む HTML メールを送信することです。
PHP コード:
<img src='http://www.domain.com/mailcheck.php?user=123'>
画像ですが、その過程でGETユーザーを追跡できます。メールヘッダーを変更して領収書を要求する方法も見つけることができますが、その方法はわかりません。また、要求が自発的であるため、信頼できません。
シンプルに、1x1 の画像を返す PHP スクリプトをセットアップします。そのスクリプトで User-Agent と IP をログに記録します (リファラーをログに記録することもできます)。
これをメールに埋め込みます。
gmail は常に画像を表示し始めましたが、独自のサーバーからそれらをホストするため、メールが開かれたかどうかを知ることはできますが、正しい IP を追跡できない場合があります。ここでいくつかの参照を確認してください: gmail キャッシュの効果とデフォルトでの画像の表示
mailchimp がどのように動作するかを知ることができます: MailChimp Working
編集:コード参照:
<img src="http://www.example.com/checkopen.php?user_id=20" />
checkopen.php
スクリプト内で、user_id
このフィールドに対応するフィールドを取得し、このユーザーがメールを開封したことを保存します。
user_id
メールを送信するときは、メールを送信するたびにフィールドをインクリメントしてください。
したがって、この画像がレンダリングされるたびに、対応する URL が呼び出されるため、メールの開封状況についてシステムにログインできます。
電子メールには、これを達成するために使用できる処分通知フィールドがあります。もちろん、これはリモート エンドの MUA に依存します。彼らは MDN を自由に無視できます (これは、他の 2 つの回答が示唆する破壊的なものではなく、丁寧な要求です)。最終受信者の MUA は、あなたのメッセージが読まれたことを知らせる電子メールをあなたに送り返します。SMTP サーバーはこれらをフィルタリングでき、送信された電子メールを応答にマップするある種のプログラムを実行できます。
[ [ 前提条件: ] ] 1. PHPMailerAutoload.php をダウンロードする必要があります。2. PHP のバージョンを確認してください。3. 共有ホスティングで phpmailer が許可されていることを確認してください。
[ [ プライバシー ポリシー ] ] 1. 受信者があなたのメールを開くと、受信者のメール サービス プロバイダーは明らかにプライバシー警告を表示します。そのため、メールを拒否された場合、必要な情報を得ることができません。
ステップ 1. 「index.php」という名前の PHP Web ページを作成します。これがフロントエンドとして機能します。メールを送信し、ここからのみ追跡します。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Email Open Tracking Using PHP</title>
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/myjs.js" type="text/javascript"></script>
<link href="css/style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="main">
<h1>Email Open Tracking Using PHP</h1>
<div id="login">
<h2>Send Email</h2>
<hr/>
<form id="form1" method="post">
<div id="box">
<input type="email" placeholder="To : Email Id " name="mailto" required/>
<input type="text" placeholder="Subject : " name="subject" required/>
<textarea rows="2" cols="50" placeholder="Meassage : This is the fixed message of test email to get notify when it is read...." name="message" readonly ></textarea>
<input type="submit" value="Send" name="send" />
</div>
</form>
<div id="loading-image"><img src="http://www.arabianbusiness.com/skins/ab.main/gfx/loading_spinner.gif" alt="Sending....."/></div>
<form id="form2" method="post">
<div id="view"></div><br><br>
<div id="readstatus"></div>
<input type="submit" value="Track Status" id="track_mail" name="track"/>
</form>
</div>
</div>
</body>
</html>
ステップ 2.「tracker.php」という名前の PHP ファイルを作成します。PHP スクリプトは、次の 2 つの目的で使用されます。
を。PHP メーラー ライブラリを使用してメールを送信します。
b. ログ ファイル (email.txt) を読んで、電子メールが開封されたかどうかを追跡します。
<?php
require ('phpmailer/PHPMailerAutoload.php');
$from = "test@gmail.com"; //sender's username
$pwd = "test@1234"; //sender's password
//-------------------------------------------------------SEND eMail----------------------------------------------------------------------
if (isset($_POST['mailto'])) {
try {
$mail = new PHPMailer(true); //New instance,exceptions enabled with true
$to = $_POST['mailto'];
$subject = $_POST['subject'];
$id = rand(111, 999);
$id.=rand(111, 999);
$body = "This is the fixed message of test email to get notify when it is read.....";
$body .= "<img border='0' src='https://yourwebsite.com/trackonline.php?email=$to&id=$id&subject=$subject' width='1' height='1' alt='image for email' >";
$mail->IsSMTP(); // tell the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP server port
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->Username = $from; // SMTP server username
$mail->Password = $pwd; // SMTP server password
$mail->From = $from;
$mail->FromName = "TESTUSER";
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->AltBody = "Please return read receipt to me."; // optional, comment out and test
$mail->WordWrap = 80; // set word wrap
$mail->MsgHTML($body);
$mail->IsHTML(true); // send as HTML
$mail->Send();
//return foll
echo '<input id="id1" name="id" type="hidden" value="' . $id . '">'
. '<input id="email1" name="email" type="hidden" value="' . $to . '">'
. '<label id="label1">Mail sent to <b>' . $to . '<b></label>';
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
}
////------------------------------------------READ email.txt-------------------------------------------------------
if (!empty($_POST['id'])) {
$id = $_POST['id'];
$to = $_POST['email'];
$checkid = "Id:" . $id;
$fh = fopen("https://yourwebsite.com/email.txt", "r");
$read = false; // init as false
while (($buffer = fgets($fh)) !== false) {
if (strpos($buffer, $checkid) !== false) {
$a = explode("%",$buffer);
$read = true;
break; // Once you find the string, you should break out the loop.
}
}
fclose($fh);
if ($read == true) {
//$string = $email . " seen the mail on subject: '" . $sub . "' from ip: " . $ipAddress . " on " . $date . " and Id:" . $id . "\n";
echo "<img id=\"closed-image\" src=\"img/envelope-open.png\" alt=\"email not opened\"/><br><p id=\"closed-para\">"
. "Mail sent from <b>" . $from . "</b><br> To <b>" . $to
. "</b><br>has been<div id=\"color-read\"> opened on <b>".$a[1]."</b></div></p>"
. "<input id=\"id1\" name=\"id\" type=\"hidden\" value=\"" . $id . "\">"; //appended hidden input to keep previous data on the page.
} else {
echo "<img id=\"closed-image\" src=\"img/envelope-closed.png\" alt=\"email not opened\"/><br><p id=\"closed-para\">"
. "Mail sent from <b>" . $from . "</b><br> To <b>" . $to
. "</b><br><div id=\"color-not-read\"> Not yet opened......</div></p>"
. "<input id=\"id1\" name=\"id\" type=\"hidden\" value=\"" . $id . "\">"; //appended hidden input to keep previous data on the page.
}
}
ステップ 3. 「trackonline.php」という名前の PHP ファイルを作成します。これは、エントリをテキスト ファイルに記録し、重複もチェックする PHP スクリプトです。
<?php
if (!empty($_GET['email'])) {
$id = $_GET['id'];
$checkid = "Id:" . $id;
$email = $_GET['email'];
$sub = $_GET['subject'];
date_default_timezone_set('Asia/Kolkata');
$date = date('d/m/Y h:i:s a');
$fh = fopen("email.txt", "a+"); //file handler
$a = fgets($fh);
$found = false; // init as false
while (($buffer = fgets($fh)) !== false) {
if (strpos($buffer, $checkid) !== false) {
$found = true;
break; // Once you find the string, you should break out the loop.
}
}
if ($found == false) {
$string = $email."opened the mail with subject:".$sub."on%".$date."% with mailId:".$id."\n";
fwrite($fh, $string);
}
fclose($fh);
//Get the http URI to the image
$graphic_http = 'https://yourwebsite.com/blank.gif';
//Get the filesize of the image for headers
$filesize = filesize('blank.gif');
//Now actually output the image requested, while disregarding if the database was affected
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Disposition: attachment; filename="blank.gif"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . $filesize);
readfile($graphic_http);
//All done, get out!
exit;
}