在Perl sendmail中,为什么我的图像附件有时会损坏?

我打算用Net :: SMTP重写它,但是现在我需要一个备份子程序,它不会“大量使用”。

在大多数电子邮件服务(Godaddy,Protonmail)中接收到该代码后,代码都可以工作并发送电子邮件,但我会得到完整的图像,而在另一个(34SP)电子邮件服务中,我只会得到图像的上半部分。

my $msg = "From: John <$sender>
To: bob <$recipient>
Subject: $subject
MIME-Version: 1.0     
Content-Type: multipart/mixed; boundary=\"BOUNDARY\"

--BOUNDARY        
Content-Type: multipart/alternative; boundary=\"MSGBOUNDARY\"

--MSGBOUNDARY
Content-Type: text/html; charset=iso-8859-1
Content-Disposition: inline

<html><body>Hello,World<br><img src=\"cid:hello\"></body></html>
--MSGBOUNDARY
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline

Hello,World,[you're missing an image here]
--MSGBOUNDARY--
--BOUNDARY
Content-Type: image/jpeg
Content-Disposition: inline; filename=\"hello.jpg\"
Content-Transfer-Encoding: base64
Content-Id: <hello>

$jpgg 
--BOUNDARY--";

open MAIL,"| $sendmail -t" 
        or die "Couldn't pipe to $sendmail";
print MAIL $msg;
close MAIL;

在Perl sendmail中,为什么我的图像附件有时会损坏?

我已经通过从另一个位置发送第一个附件来测试了34SP电子邮件服务,并且可以很好地接收它,因此代码一定有问题。如果有人看到我做错了什么,我将不胜感激。

EDIT(1);根据Polar Bears的建议,我已经编辑了代码以方便阅读,我已经测试了此版本,但仍然遇到相同的问题。

jsxzxuhu 回答:在Perl sendmail中,为什么我的图像附件有时会损坏?

只是建议将代码更改为以下形式

<SiteName>.azurewebsites.net
本文链接:https://www.f2er.com/2945666.html

大家都在问