-1

因此,我正在尝试创建一个通过 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.

感谢您的帮助/阅读时间

4

1 回答 1

2

第 60 行缺少分号。

而不是Email::Send,使用Email::Senderwith Email::Sender::Transport::SMTP::TLS

于 2013-06-28T06:48:13.657 回答