-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、 with を使用Email::SenderEmail::Sender::Transport::SMTP::TLSます。

于 2013-06-28T06:48:13.657 に答える