6

有人知道以下问题的任何解决方案吗

在我的项目中,我使用 smtp 和 php mailer 和 gmail 脚本向客户端发送电子邮件。所以当我发送邮件时,gmail 发送邮件给特定的客户。为此,我正在传递有效的 gmail 登录名和用户名。所有邮件都正确发送。但有时可能会发生某些客户未收到邮件的情况,当时我无法获取或跟踪任何错误。所以我有任何办法,当我向客户发送邮件时,当客户收到并阅读它时,我得到了任何形式的确认。

如果有人有任何想法,请帮助我。

4

3 回答 3

1
<?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();
}
?>

需要在上面的脚本中进行一些修改。

  1. 配置 SMTP 邮件服务器。

  2. 设置正确的 FROM & FROM Name (someone@something.com, SOMEONE)

  3. 设置正确的 TO 地址

  1. PHP 邮件中的投递报告和已读回执
于 2013-04-06T05:58:02.597 回答
0

您可以通过两种不同的方式检查事情,例如通过在您的邮件功能中使用标题“Disposition-Notification-To”,它不会在所有情况下都起作用,因为大多数人选择不发送已读回执。如果您可以从您的服务器影响这是否发生,垃圾邮件发送者可以很容易地轻松识别活动和非活动电子邮件地址。您可以设置标题

$email_header .= "Disposition-Notification-To: $from"; 
$email_header .= "X-Confirm-Reading-To: $from";

现在检查的另一种方法是放置图像,您可以添加一个脚本来加载该图像,该脚本将向您的系统发送通知,告知您 xxx 用户已阅读邮件,这样您就可以跟踪邮件的发送状态邮件。

事实上,我想不出任何方法来确认它已经交付,而不检查它是否被读取,或者通过包含从您的服务器请求并记录为已访问的图像,或者用户必须访问的链接到查看消息的完整内容。

两者都不能保证(并非所有电子邮件客户端都会显示图像或使用 HTML),并且并非所有“已传递”的消息都会被阅读。

虽然有关更多信息https://en.wikipedia.org/wiki/Email_tracking

于 2013-04-06T06:32:48.447 回答
0

您可以随时添加回复邮件地址,如果有任何错误,您会收到电子邮件,如果已阅读,请附上一张图片(1像素的空白图片即可)并在该图片中添加代码,例如和您可以查看该图像确实收到了多少点击或根本没有收到任何点击。

于 2013-04-06T05:50:48.627 回答