PHP:检查谁看过发送的电子邮件? [英] PHP: Check who had read sent email?
问题描述
我正在向某些用户发送电子邮件,并想知道谁阅读了该电子邮件,这意味着如果有人阅读了该电子邮件,则将维护一个日志文件,其中包含该用户的电子邮件地址以及日期/时间/IP. 为此,我发送了一个带有电子邮件(html模板)的javascript函数,该函数仅在用户打开该电子邮件时提醒用户的电子邮件地址,例如:
I am sending email to some users and wants to know who had read it, means if some one had read that email then a log file will maintain which contain the email address of that user with date/time/IP. For this I send a javascript function with the email (html template) which just alert the email address of the user when ever a user opens that email like:
for($n=0; $n<sizeof($checkBox); $n++){
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->Subject = $subject;
$function = "<script language='javascript'>function stats(emailId){alert(emailId);}</script>";
$bodyOpen = "<body onload='stats(".$checkBox[$n].");'>";
$msg_body .= $body .= "<table><tr><td>Hello Everyone</td></tr></table></body>";
$mail->Body = $function.$bodyOpen.$msg_body;
$mail->WordWrap = 50;
$mail->FromName = 'Muhammad Sajid';
$mail->IsMAIL();
$mail->From = 'webspot49@gmail.com';
$mail->AddAddress($checkBox[$n]);
$sent = $mail->Send();
}
该html模板可以正常工作,并在页面加载时显示一个警报弹出窗口,但是如果我用来发送此html模板,则它不起作用.
the html template works fine and shows an alert popup on page load but it does not works if I use to send this html template.
我只想使用PHP5.x.x/javascript解决此问题,而不需要其他软件或第三方工具. 任何帮助..?
And I only want to solve this issue using PHP5.x.x / javascript, no other software or third party tool. Any help..?
推荐答案
将标题添加到电子邮件:
Add Header to email:
Disposition-Notification-To: you@yourdomain.com
如上所述,这是不可靠的,最好执行以下操作:
As mentioned above it's not reliable and it's better to do something like this:
<img src="http://yourdomain.com/emailreceipt.php?receipt=<email of receiver>" />
并将其记录在数据库中,尽管这又受到电子邮件客户端显示图像的能力的限制,有时它甚至可能由于无法检测到图像而将邮件放入垃圾中,这是一种解决方法实际在该脚本的末尾输出图像(例如徽标).
And log it in a database, although again this is restricted by the email client's ability to show images and sometimes it may even put the mail into junk because it doesn't detect an image... a workaround that would be to actually outputting an image (say your logo) at the end of that script.
快速查看phpmailer类可以得到以下信息:
A quick lookup at the phpmailer class gave me the following:
$mail->ConfirmReadingTo = 'yourown@emailaddress.com';
但与上面的Disposition-Notification-To方法相同.
but it's the same as the Disposition-Notification-To method above.
这篇关于PHP:检查谁看过发送的电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!