所以我正在尝试创建一个通过gmail发送电子邮件的脚本,我在这个网站上看了几个例子,但是它没有用,所以我想我会问并测试我的运气。 继承人代码:
use strict;
use warnings;
use Email::Send;
use Email::Simple::Creator;
use Email::Send::SMTP::Gmail;
use Email::Send::Gmail;
use lib 'lib';
my $seeky = <"seekers">;
print (" What would you like to do ?: \n 1.Send Email \n 2. Send email with attachment \n 3. quit");
my $requ = <>;
if ($requ =~ /("1")/)
{
print ("Enter your email address: ");
my $addrs = <>;
print ("Enter address to who to send this to");
my $target = <>;
my $pwwd = <>;
print("Enter body message here");
my $boddy = <>;
my $email = Email::Simple->create(
header => [
From => " $addrs ",
To => " $target",
Subject => 'Untitled',
],
body => "$boddy",
);
my $sender = Email::Send->new(
{ mailer => 'Gmail',
mailer_args => [
username => "$addrs",
password => "$pwwd",
]
}
);
eval { $sender->send($email) };
die "Error sending email: $@" if $@;
seek("seekers", 0, 1);
}
if ($requ =~ /("2")/)
{
print ("Enter your email address: ");
my $addrs = <>;
print ("Enter address to who to send this to");
my $target = <>;
my $pwwd = <>;
print("Enter body message here");
my $boddy = <>;
print("Path to file: ")
my $ptf = <>;
my $mail = Email::Send::SMTP::Gmail->( -smtp => 'smtp.gmail.com'
-login=> "$addrs"
-pass => "$pwwd");
$mail->send( -to => "$target",
-subject => 'Untitled',
-body => "$boddy",
-attachments => "$ptf");
$mail->bye;
seek("seekers", 0, 1);
}
if($requ =~ /("3")/ ) {
system( [0,1,2], $^X, "alice_.pl", @ARGS);
}
以下是错误消息:
Return::Value is deprecated at /usr/local/share/perl/5.14.2/Return/Value.pm line 13
require Return/Value.pm called at /usr/local/share/perl/5.14.2/Email/Send.pm line 11
Email::Send::BEGIN() called at /usr/local/share/perl/5.14.2/Return/Value.pm line 0
eval {...} called at /usr/local/share/perl/5.14.2/Return/Value.pm line 0
require Email/Send.pm called at email_.pl line 3
main::BEGIN() called at /usr/local/share/perl/5.14.2/Return/Value.pm line 0
eval {...} called at /usr/local/share/perl/5.14.2/Return/Value.pm line 0
syntax error at email_.pl line 61, near ")
my "
Global symbol "$ptf" requires explicit package name at email_.pl line 61.
Global symbol "$ptf" requires explicit package name at email_.pl line 69.
Global symbol "@ARGS" requires explicit package name at email_.pl line 76.
Execution of email_.pl aborted due to compilation errors.
感谢您的帮助/时间阅读
答案 0 :(得分:2)
第60行缺少分号。
而不是Email::Send
,请将Email::Sender
与Email::Sender::Transport::SMTP::TLS
一起使用。