我需要向 gmail 发送一封包含一些内联图像的电子邮件。
我使用 perl 和 MIME:LITE,但 Gmail 将我的图像显示为附件,而不是内联。
有什么问题?
这是我的代码,
use MIME::Lite;
my $texto = '<html><body>hola <img src="cid:image" /> adios </body></html>';
#
my $msg = MIME::Lite->new(
Date => "Xxx, 22 Oct 2012 17:45:00 CET",
From => "pruebachunga@aqui.com",
To => 'chimpun@forum.chimpun',
Subject => "En un lugar de la mancha",
'Message-ID' => '123456789012345656789@8888888888888ldkf',
Type =>'multipart/related'
);
$msg->attach(
Type => 'text/html',
Data => $texto,
Encoding => 'quoted-printable'
);
$msg->attach(
Encoding => 'base64',
Type => 'image/png',
Path => "image.png",
Id => "image"
);
$msg->scrub(['x-mailer', 'Content-Disposition']);
print $msg->as_string;
结果就是这封电子邮件(我剥离了图像部分)
Content-Transfer-Encoding: binary
Content-Type: multipart/related; boundary="_----------=_135100636840600"
MIME-Version: 1.0
Date: Xxx, 22 Oct 2012 17:45:00 CET
From: pruebachunga.com
To: chimpun@forum.chimpun
Subject: En un lugar de la mancha
Message-Id: 123456789012345656789@8888888888888ldkf
This is a multi-part message in MIME format.
--_----------=_135100636840600
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html
<html><body>hola <img src=3D"cid:image" /> adios </body></html>=
--_----------=_135100636840600
Content-Id: <image>
Content-Transfer-Encoding: base64
Content-Type: image/png; name="image.png"
iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAMAAAEwO1XwAAAAB3RJTUUH1gYE
...
kmqg1wGgkx35p/KStnLuw2BGhXwIZqT+D8sxTLVK0VpuAAAAAElFTkSuQmCC
--_----------=_135100636840600--
编辑:
在网上阅读后,我认为该图像是附件并且存在称为“图像阻塞”的问题:https ://www.campaignmonitor.com/resources/guides/image-blocking-in-email/
我保留了我的问题,因为人们可能会觉得这个问题很有趣。现在,我认为这段代码是正确的,并且与其他消息,其他ID,其他发送者......这段代码可以运行良好。