电子邮件正文 img 标签上的联系表格 7 图像

pag*_*gol 5 contact-form-7

我想创建一份包含文件/图像上传的提交表单。公司徽标/图片等的图像。通常我知道如何附加图像,作为邮件中的附件,但我希望将图像作为图像标签附加在邮件正文上,这样当我打开电子邮件时,我可以看到所有包含图像的文件,然后打印来自电子邮件。

下面的电子邮件示例

<table width="500" border="1" cellspacing="0" cellpadding="0">
  <tbody>
    <tr>
      <th scope="row">Your Name</th>
      <td>[your-name]</td>
    </tr>
    <tr>
      <th scope="row">Your Email</th>
      <td>[your-email]</td>
    </tr>
    <tr>
      <th scope="row">Subject</th>
      <td>[your-subject]</td>
    </tr>
    <tr>
      <th scope="row">Your Message</th>
      <td>[your-message]</td>
    </tr>
    <tr>
      <th scope="row">Picture</th>
      <td><img src="[file-305]"></td>
    </tr>
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

有什么方法可以发送邮件正文中图像标签上的图像,或者可以将其作为 pdf 文件完整发送吗?

如果有任何免费或付费插件也可以。

Tsc*_*cka 0

我建议您稍微修改一下电子邮件撰写例程,并将 Base64 图像作为内联图像包含在内。

首先使用如何将图像转换为 Base64 编码? 将图像转换为 Base64

$path = 'path/to/uploaded-file/myimage.png';
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
Run Code Online (Sandbox Code Playgroud)

然后使用在 html 电子邮件中嵌入图像将其包含在您的电子邮件中

<img src="<?= $base64 ?>" />
Run Code Online (Sandbox Code Playgroud)

大多数电子邮件客户端应该很容易接受它。否则,您始终可以参考附件电子邮件中的内容 ID

<img src="cid:part1xxxxxxxxxx" alt="">
Run Code Online (Sandbox Code Playgroud)