gpt4 book ai didi

php - 使用SMTP,PHPmailer发送邮件时如何知道用户发送和阅读邮件

转载 作者:可可西里 更新时间:2023-11-01 13:30:40 26 4
gpt4 key购买 nike

有没有人知道以下问题的解决方案

在我的项目中,我使用 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();
}
?>

上面的脚本需要做一些修改。

  1. 配置 SMTP 邮件服务器。

  2. 设置正确的 FROM 和 FROM 名称(someone@something.com、SOMEONE)

  3. 设置正确的TO地址

from

还有

  1. Delivery reports and read receipts in PHP mail

关于php - 使用SMTP,PHPmailer发送邮件时如何知道用户发送和阅读邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15847476/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com