有人知道下面这个问题的解决方案吗
在我的项目,我发送电子邮件到客户端使用SMTP和PHP邮件和gmail脚本。所以当我发送邮件时,gmail会将邮件发送给特定的客户端。为此,我通过gmail登录和用户名,这是有效的。所有邮件都发送正常。但有时可能会发生一些客户没有收到邮件,那时我无法获得或跟踪任何错误。所以我有任何方式,当我发送邮件给客户,当客户收到并阅读它的时候,我得到了任何形式的确认。
<?php
/**
* Simple example script using PHPMailer with exceptions enabled
* @package phpmailer
* @version $Id$
*/
require ('../class.phpmailer.php');
try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled
$body = "Please return read receipt to me.";
$body = preg_replace('/''''/','', $body); //Strip backslashes
$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 SERVER IP/DOMAIN"; // SMTP server
$mail->Username = "EMAIL USER ACCOUNT"; // SMTP server username
$mail->Password = "EMAIL USER PASSWORD"; // SMTP server password
$mail->IsSendmail(); // tell the class to use Sendmail
$mail->AddReplyTo("someone@something.com","SOMEONE");
$mail->From = "someone@something.com";
$mail->FromName = "SOMEONE";
$to = "other@something.com";
$mail->AddAddress($to);
$mail->Subject = "First PHPMailer Message[Test Read Receipt]";
$mail->ConfirmReadingTo = "someone@something.com"; //this is the command to request for read receipt. The read receipt email will send to the email address.
$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();
echo 'Message has been sent.';
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
?>
上面的脚本需要做一些修改。
配置SMTP邮件服务器
设置正确的FROM &FROM Name (someone@something.com, SOMEONE)
设置正确的TO地址
- 在PHP邮件中发送报告和读取收据
你总是可以添加回复邮件地址,这将照顾,如果有任何错误,所以你会收到电子邮件,如果它被读取,包括一张图片(1像素的空白图片将做),并在图片中添加代码,你可以看到有多少点击,该图像确实收到或收到任何。
你可以通过两种不同的方式来检查这些事情,比如,在你的邮件功能中使用标题"处置-通知-收件人",它不会在所有情况下都起作用,因为大多数人选择不发送阅读收据。如果您可以从服务器影响是否发生这种情况,垃圾邮件发送者可以很容易地识别活动和非活动电子邮件地址。你可以设置像
这样的标题$email_header .= "Disposition-Notification-To: $from";
$email_header .= "X-Confirm-Reading-To: $from";
现在另一种检查方法是放置一个图像,你可以添加一个脚本来加载该图像,该脚本将发送通知到你的系统,XXX用户已经阅读了邮件,这样你就可以跟踪邮件的发送状态。
事实上,如果不检查它是否被阅读,我想不出任何方法来确认它是否被传递,要么包括一个从服务器请求的图像,并记录为已被访问,或者用户必须访问一个链接才能看到消息的全部内容。
两者都不能保证(不是所有的电子邮件客户端都会显示图像或使用HTML),也不是所有的"发送"消息都将被读取。
虽然要了解更多信息https://en.wikipedia.org/wiki/Email_tracking