linux – Shell脚本使用sendmail嵌入多个图像
发布时间:2020-12-31 02:13:32 所属栏目:Linux 来源:网络整理
导读:我正在使用以下脚本使用sendmail功能在邮件上嵌入多个图像. sendmail -t EOTTO: example_to@xyz.comFROM: example_from@xyz.comCc: example_cc@xyz.comSUBJECT: Phobos Report MIME-Version: 1.0Content-Type: multipart/related;boundary="XYZ"--XYZContent
我正在使用以下脚本使用sendmail功能在邮件上嵌入多个图像. sendmail -t <<EOT TO: example_to@xyz.com FROM: example_from@xyz.com Cc: example_cc@xyz.com SUBJECT: Phobos Report MIME-Version: 1.0 Content-Type: multipart/related;boundary="XYZ" --XYZ Content-Type: text/html; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit <html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-15"> </head> <body bgcolor="#ffffff" text="#000000"> <img src="cid:part1.06090408.01060107" alt=""><br/> <img src="cid:part2.06090408.01060107" alt=""><br/> <img src="cid:part3.06090408.01060107" alt=""> </body> </html> --XYZ Content-Type: image/jpeg;name="rag1.jpg" Content-Transfer-Encoding: base64 Content-ID: <part1.06090408.01060107> Content-Disposition: inline; filename="rag1.jpg" $(base64 rag1.jpg) --XYZ Content-Type: image/jpeg;name="rag2.jpg" Content-Transfer-Encoding: base64 Content-ID: <part2.06090408.01060107> Content-Disposition: inline; filename="rag2.jpg" $(base64 rag2.jpg) --XYZ Content-Type: image/jpeg;name="rag3.jpg" Content-Transfer-Encoding: base64 Content-ID: <part3.06090408.01060107> Content-Disposition: inline; filename="rag3.jpg" $(base64 rag3.jpg) --XYZ-- EOT 这里只有第一张图片被嵌入.所有其他人都没有被添加.这两个图像被添加为基于文本的附件.如何在此脚本上添加多个图像? 解决方法这是一个老问题,但我认为无论如何都值得回答.您的代码的问题是您在MIME边界和最后两个图像的MIME标头之间放置空行,如下所示: --XYZ Content-Type: image/jpeg;name="rag2.jpg" Content-Transfer-Encoding: base64 Content-ID: <part2.06090408.01060107> Content-Disposition: inline; filename="rag2.jpg" 这是不允许的.您应该更正代码并在两个位置删除这些空行,如下所示: --XYZ Content-Type: image/jpeg;name="rag2.jpg" Content-Transfer-Encoding: base64 Content-ID: <part2.06090408.01060107> Content-Disposition: inline; filename="rag2.jpg" 和这里: --XYZ Content-Type: image/jpeg;name="rag3.jpg" Content-Transfer-Encoding: base64 Content-ID: <part3.06090408.01060107> Content-Disposition: inline; filename="rag3.jpg" 在边界线之前允许空行,这意味着它们将成为前一个主体的一部分,在那里它们通常是无害的(但是我可以在它们不存在的情况下构成上??下文.但是,不是你的情况.) 最好不要在MIME边界的任何一侧放置额外的空行.当然,这不是第一个MIME边界之前所需的空行,它分隔MIME头. (编辑:威海站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |