通过亚马逊的SES API发送内联字符串

时间:2015-12-04 06:13:16

标签: amazon amazon-ses

我正在尝试通过amazon发送条形码和我的html邮件内容。我正在使用SES服务。

在邮件中,img标签添加了src =“cid:barcodeImage”

和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中发送嵌入的图像?

1 个答案:

答案 0 :(得分:0)

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

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

希望这可以解决您的问题,并让我知道是否有任何问题

相关问题