perl Email::Send 与 gmail 失败与图像
perl Email::Send with gmail fails with images
此问题与 HTML image not showing in Gmail 相关,但那里的答案无效(或不再有效)。
问题是当我的 html 格式的消息包含 img 标签后我想立即发送时,我的 perl 程序(如下)失败。图片本身是否由 google 驱动器提供并不重要。我猜我 运行 遇到了新的 gmail 限制(我的脚本曾经有效),但我不确定。
(当然,这个问题不是我的收件人看不到图像;而是发送 perl 脚本因错误而中止---不幸的是,没有更多信息向我解释为什么这是一个错误.当然,我明白我的收件人需要同意查看图像以防止跟踪。)
所以这是我的问题:
这是 gmail 还是 perl 模块的问题?
是否可以发送图像,以便如果我的收件人想要看到
来自我网站的图片(最好不仅仅是来自我的 google 驱动器的图片,如下面的示例),他们可以同意看到这个吗?
是否可以从 google 获得关于失败原因的更好的错误消息?
这里是[几乎]工作代码:
#!/usr/bin/perl -w
use strict;
use warnings;
use Email::MIME::CreateHTML;
use Email::Send;
use Email::Send::Gmail;
my $toemail = 'ivo.welch@gmail.com';
my $subject = 'testing image mailing';
my $bodytext= '<html> <body> fails: <img src="https://drive.google.com/open?id=1K4psrWWolTSqx_f6MQP-T1-FMFpegT1Trg" alt="photo" /> </body> </html>\n';
use readcredentials;
my $gmailaccount= readcredentials( 'account' );
my $gmailuserlogin= readcredentials( 'userlogin');
my $gmailpasswd= readcredentials( 'gmailpassword');
eval {
my $message = Email::MIME->create_html(
header => [
From => $gmailaccount,
To => $toemail,
Subject => $subject,
],
body => $bodytext,
);
my $sender = Email::Send->new(
{ mailer => 'Gmail',
mailer_args => [
username => $gmailuserlogin,
password => $gmailpasswd,
]
}
);
$sender->send($message);
};
warn "Error sending email: $@" if $@;
print STDERR "emailed!\n";
我 运行 您的脚本,进行了一些修改以删除对 readcredentials
的依赖,使其在我的环境中成为 运行,并且电子邮件已顺利发送。问题可能是:
- 您的 gmail 凭据可能有一些问题。
- 脚本会下载并附加图像,因此您的本地环境可能阻止了图像的下载。
但是如果没有您的具体错误信息,很难进一步诊断。
此问题与 HTML image not showing in Gmail 相关,但那里的答案无效(或不再有效)。
问题是当我的 html 格式的消息包含 img 标签后我想立即发送时,我的 perl 程序(如下)失败。图片本身是否由 google 驱动器提供并不重要。我猜我 运行 遇到了新的 gmail 限制(我的脚本曾经有效),但我不确定。
(当然,这个问题不是我的收件人看不到图像;而是发送 perl 脚本因错误而中止---不幸的是,没有更多信息向我解释为什么这是一个错误.当然,我明白我的收件人需要同意查看图像以防止跟踪。)
所以这是我的问题:
这是 gmail 还是 perl 模块的问题?
是否可以发送图像,以便如果我的收件人想要看到 来自我网站的图片(最好不仅仅是来自我的 google 驱动器的图片,如下面的示例),他们可以同意看到这个吗?
是否可以从 google 获得关于失败原因的更好的错误消息?
这里是[几乎]工作代码:
#!/usr/bin/perl -w
use strict;
use warnings;
use Email::MIME::CreateHTML;
use Email::Send;
use Email::Send::Gmail;
my $toemail = 'ivo.welch@gmail.com';
my $subject = 'testing image mailing';
my $bodytext= '<html> <body> fails: <img src="https://drive.google.com/open?id=1K4psrWWolTSqx_f6MQP-T1-FMFpegT1Trg" alt="photo" /> </body> </html>\n';
use readcredentials;
my $gmailaccount= readcredentials( 'account' );
my $gmailuserlogin= readcredentials( 'userlogin');
my $gmailpasswd= readcredentials( 'gmailpassword');
eval {
my $message = Email::MIME->create_html(
header => [
From => $gmailaccount,
To => $toemail,
Subject => $subject,
],
body => $bodytext,
);
my $sender = Email::Send->new(
{ mailer => 'Gmail',
mailer_args => [
username => $gmailuserlogin,
password => $gmailpasswd,
]
}
);
$sender->send($message);
};
warn "Error sending email: $@" if $@;
print STDERR "emailed!\n";
我 运行 您的脚本,进行了一些修改以删除对 readcredentials
的依赖,使其在我的环境中成为 运行,并且电子邮件已顺利发送。问题可能是:
- 您的 gmail 凭据可能有一些问题。
- 脚本会下载并附加图像,因此您的本地环境可能阻止了图像的下载。
但是如果没有您的具体错误信息,很难进一步诊断。