来自Perl的电子邮件,找不到对象方法Create

时间:2014-12-09 05:20:26

标签: perl

我正在尝试编写一个脚本,该脚本将使用Perl从服务器发送Gmail。代码如下所示。

use warnings;
use strict;
use Email::Sender;
use Email::Send::Gmail;
use Email::Simple::Creator;

my $email = Email::Simple->create (
  header => [
    From    => 'xxxx@gmail.com',
    To      => 'yyyyy@gmail.com',
    Subject => 'Oh no! The bathwater is overflowing!',
  ],
  body => 'The bath water is overflowing.',
);
my $sender = Email::Send->new ({
    mailer      => 'Gmail',
    mailer_args => [
        username => 'xxxxx',
        password => 'yyyyy',
    ]
});

$sender->send ($email);
For which I get the error  `Can't locate object method "create" via package "Email::Simple" at file.pl line 9.`

导致此错误的原因是我安装了Email :: Simple Module和Gmail Modules。

1 个答案:

答案 0 :(得分:4)

您错过了use Email::Simple; perldoc suggests