【问题标题】:Sending inline strings through SES API of Amazon通过 Amazon 的 SES API 发送内联字符串
【发布时间】:2015-12-04 06:13:15
【问题描述】:

我正在尝试通过亚马逊发送条形码以及我的 html 邮件内容。我正在使用 SES 服务。

在邮件中添加了 src="cid:barcodeImage" 的 img 标签

和ses代码是

if (is_array($files)) {

$count = count($files);
        foreach ($files as $file) {
            $attach .= "\n";
            $attach .= "--$this->boundary\n";
            $attach .= "Content-Transfer-Encoding: base64\n";
            $attach .= "Content-ID: <$file[cid]>\n";
            $clean_filename = self::clean_filename($file["name"], self::MAX_ATTACHMENT_NAME_LEN);
            $attach .= "Content-Type: application/octet-stream; name=$clean_filename;\n";
            $attach .= "Content-Disposition: inline; filename=$clean_filename;\n";
            $attach .= "\n";
            $attach .= chunk_split(base64_encode($file['string']), 76, "\n");
            $attach .= "\n--$this->boundary";
        }
        // close email
        $attach .= "--\n";
    }

但不是作为嵌入字符串出现,而是作为邮件附件出现 是否可以在 amzon ses 中发送嵌入图像?

【问题讨论】:

  • 你为什么不写一个纯 html 正文电子邮件并从绝对 url 调用图像?您将能够减轻电子邮件本身的重量,如果您将图像添加到 CDN 中,下载速度会更快。
  • 有些邮件不会显示外部网址

标签: amazon amazon-ses


【解决方案1】:

我通过将图像源提供为 base64 编码数据来解决此问题。在python中我这样做:

    x = 'data:image/png;base64,{}'.format(base64.b64encode(open('x.png', 'rb').read()).decode())

希望这能解决您的问题,如果有任何问题,请告诉我

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-03
    • 1970-01-01
    • 1970-01-01
    • 2013-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-12
    相关资源
    最近更新 更多