php - 包含 HTML 作为字符串的 PHP 变量 - 需要转换为图像或 PDF - 通过电子邮件发送响应
问题描述
我正在发送电子邮件表单 php 代码,一旦发送电子邮件,我的电子邮件正文是 HTML 背景图像未显示在 Outlook 桌面应用程序中,但它在 Outlook Web 邮件中工作正常,如何使其在桌面 Outlook 应用程序中可见
因此,我正在考虑将电子邮件正文转换为 pdf 或图像,以便我可以将其添加为邮件正文
谁能指导我做
$emailBody='<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
#textDiv{
background-image: url("appreciation-'.$imageId.'.jpg");background-repeat: no-repeat;width:595px;height: 842px;color: white;float: center;
}
#p1{
padding-top: 420px;padding-left: 50px;width: 500px;font-size: large;
}
#p2{
padding-top: 30px;padding-left: 50px;width: 500px;font-size: 25px;
}
</style>
</head>
<body>
<center>
<div id="textDiv" align="center" style="font-family: cursive; text-align:center;">
<p id="p1">Hi '.$actReciverName.', you have received Kudos from '.$senderName.' </p>
<p id="p2"><i><u>"'.$comment.'"</u></i></p>
</div>
</center>
</body>
</html>'
提前感谢您的支持
解决方案
在电子邮件正文/模板中添加图像作为背景不是最佳做法,如果需要,这里有一些针对 IE 和 Outlook 的hack,因为这些电子邮件阅读器基于 MS Word,因此有必要在 IE 注释中添加一些 XML 和特殊标签到 HTML代码。
例子:
<div style="background-color:#7bceeb;">
<!--[if gte mso 9]>
<v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
<v:fill type="tile" src="https://i.imgur.com/YJOX1PC.png" color="#7bceeb"/>
</v:background>
<![endif]-->
<table height="100%" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top" align="left" background="https://i.imgur.com/YJOX1PC.png">
... your content here ...
</td>
</tr>
</table>
</div>
注意对于电子邮件,<table>
请尽可能多地使用<div>
推荐阅读
- php - 表单提交、自动电子邮件和 jquery
- django - 如何在“django-rest-framework-simplejwt”中使用“电子邮件”而不是“用户名”来生成令牌?
- gnuplot - 覆盖 Gnuplot 多图布局
- django - django 后端的身份验证
- php - 如何使用 PHP 或 cURL 获取真正的最终重定向 URL?
- node.js - 遵循 Mongodb 模型的最佳建模方法是什么
- vba - vba if 语句中的对象需要运行时错误 424
- c - 我可以通过其他文件中的指针来操作文件范围变量/数组吗?
- php - 如何在从文本到图像创建的 php 图像中使用我的此代码添加背景颜色?
- excel - 循环浏览 DV 列表并将所有数据选择打印到一个 pdf 文件