开发者

How can I send mail to Gmail with an attachment, in Perl?

开发者 https://www.devze.com 2022-12-08 06:15 出处:网络
How can I send mail to Gmail using Perl? Here\'s what I\'m trying: my $mailer = Email::Send->new( { mailer=> \'SMTP::TLS\',

How can I send mail to Gmail using Perl? Here's what I'm trying:

my $mailer = Email::Send->new(
    {
        mailer      => 'SMTP::TLS',
        mailer_args => [
            Host     => 'smtp.gmail.com',
            Port     => 587,
            User     => 'xxx',
开发者_运维知识库            Password => 'xxx',
        ]
    }
);

use Email::Simple::Creator;    # or other Email::

use File::Slurp;
@arrIrc = read_file("$ircFile");
my $email = Email::Simple->create(
    header => [
        From    => 'xxx',
        To      => "$configList{email}",
        Subject => "The summary of logfile $channelName",
    ],
    body => "@arrIrc",
);


Use Net::SMTP::SSL to talk to GMail.

See MIME::Lite inline images on Perlmonks for an example.


If you want to send mail to Gmail, you do the same thing you would do to send mail anywhere. If you want to send mail through Gmail, there is the Email::Send::Gmail module. Merely typing your question in Google led me to Sending Mail Through Gmail with Perl by Mark Sanborn.


You can use MIME::Lite to compose a message, which you then send to your local sendmail process. However, in order to talk to gmail's servers you need to have SSL certificates set up. There's probably more detailed instructions for that on superuser.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号