我正在尝试使用脚本发送 HTML 电子邮件。我将不得不使用 native unix 东西和 Email::Mime
因为这些是我发现安装在我所坚持的盒子里的唯一东西。我正在创建一条 Email::Mime
消息并将其发送到 sendmail。
但我不断收到错误: header 中找不到收件人地址
我见过其他使用 sendmail
的 RUBY 脚本,因此适用于此框。
有人可以帮我解决下面代码片段中可能做错的事情吗?
sub send_mail(){
use MIME::QuotedPrint;
use HTML::Entities;
use IO::All;
use Email::MIME;
# multipart message
my @parts = (
Email::MIME->create(
attributes => {
content_type => "text/html",
disposition => "attachment",
encoding => "quoted-printable",
charset => "US-ASCII",
},
body_str => "Hello there!",
),
);
my $email = Email::MIME->create(
header_str => [
To => '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9afbf8f9dae2e2e2b4f9f5f7" rel="noreferrer noopener nofollow">[email protected]</a>',
From => '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9b8bbba99a1a1a1f7bab6b4" rel="noreferrer noopener nofollow">[email protected]</a>',
Subject => "Test Email",
],
parts => [@parts],
);
# die $email->as_string;
# die YAML::XS::Dump(\%mail);
open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL $email;
close (MAIL);
}
提前致谢。
最佳答案
print MAIL $email;
应该是
print MAIL $email->as_string;
关于perl - 如何将 Email::Mime 与 sendmail 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53453265/