我想知道是否可以在PHPMailer中隐藏正文消息的某些部分,具体取决于电子邮件地址。我有2个电子邮件地址正在发送邮件,第二个电子邮件地址只需要查看第一个电子邮件地址所看到的部分内容。有没有办法确定我只想要第一个电子邮件地址来查看内容。例如:
$mail = new PHPMailer();
$mail->AddReplyTo($fromemail, "".$fromname."");
$mail->AddReplyTo("emailaddress1@abc.com", "Company ABC");
$mail->SetFrom($fromemail, "".$fromname."");
$mail->AddAddress("emailaddress1@abc.com", "Company ABC");//would see the whole email
$mail->AddAddress("partneraddress@somecompany.com", "Partner Company");//would only see 1st paragraph
$subject = "Email Subject";
$mail->AltBody = "To view this message, please use an HTML compatible email viewer";
$mail_body .= "
<html>
<head>
<title>Email Message</title>
</head>
<body>
<p>This would be a paragraph that both email addresses see</p>";
if ($mail->AddAddress == "emailaddress1@abc.com") {
$mail_body .= "<p>This would only be seen by the first address</p>";
}
$mail_body .= "</body>
</html>";
答案 0 :(得分:1)
如果没有向收件人发送两条不同的邮件,并且具有不同的正文内容,则无法进行此操作。虽然有些邮件客户端可能仍然支持和执行Javascript而无需用户干预(我对此表示怀疑),但根本不能依赖它。