我希望在修改后的 php-mailer 中插入回复按钮



>我创建了一个在电子邮件客户端中工作的代码,如下所示:

<html>
<head>
<title>PLEASE REPLY USING THE BUTTONS</title>
</head>
<body>
<table cellspacing="5" cellpadding="5" border:5px;>
<tr>
<td align="center" width="200" height="40" bgcolor="#000091" style="-webkit-    border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;" >
<a href="mailto:xxx@xxx.com?subject=ATTENDING" style="font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; line-height:40px; width:100%; display:inline-block"><span style="color: #FFFFFF">ATTENDING</span></a>
</td>
<td height="10"></td>
<td align="center" width="200" height="40" bgcolor="#000091" style="-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;">
<a href="mailto:xxx@xxx.com?subject=DINING" style="font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; line-height:40px; width:100%; display:inline-block"><span style="color: #FFFFFF">ATTENDING AND DINING</span></a>
</td>
<td height="10"></td>
<td align="center" width="200" height="40" bgcolor="#000091" style="-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;">
<a href="mailto:xxx@xxx.com?subject=APOLOGIES" style="font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; line-height:40px; width:100%; display:inline-block"><span style="color: #FFFFFF">APOLOGIES</span></a>
</td>
</tr>
</table>
</body>
</html>

现在修改为包括 html、标题、正文。它适用于网页,也适用于电子邮件客户端。

但是把它放在php-mailer的正文中会完全忽略它。

如何确保这些按钮出现在邮寄的文本中。

我不明白 Yii:: 的响应,因为页面只是卡住了。 有没有更简单的方法可以将 html 放入页面?

感谢您的帮助

华润集团

在代码中使用setHtmlBody

public function sendEmail($email)
{
return Yii::$app->mailer->compose()
->setTo($email)
->setFrom([$this->email => $this->name])
->setSubject('text')
->setHtmlBody($this->body)
->send();
}

由于各种原因,电子邮件 html 与普通 html 有很大不同,安全性就是其中之一。许多电子邮件客户端完全忽略 mailto 链接,实现不佳或向用户显示警告。

最好避免它。您可以使用电子邮件中或网站上的表单来允许用户向您发送消息。

参考: https://www.campaignmonitor.com/blog/email-marketing/2013/06/tip-avoid-using-mailto-links-in-html-email/

最新更新