如何使用 SMTP 和 Perl 向我的 Gmail 帐户发送电子邮件? [英] How do I send email to my Gmail account using SMTP and Perl?

查看:36
本文介绍了如何使用 SMTP 和 Perl 向我的 Gmail 帐户发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想使用 sendmail 发送电子邮件,但更喜欢使用 SMTP.如何使用 Perl 向我的 GMAIL 帐户发送电子邮件?

I don't want to use sendmail to send an email but would prefer to use SMTP. How can I use Perl to send an email to my GMAIL account?

推荐答案

我个人建议你使用我的模块 Email::Send::SMTP::TLS它通过 Google Mail 的 TLS 运行良好.

personally I would suggest you to use my module Email::Send::SMTP::TLS which works pretty well through the TLS of Google Mail.

谢谢.

use Email::Send;

my $mailer = Email::Send->new( {
    mailer => 'SMTP::TLS',
    mailer_args => [
        Host => 'smtp.gmail.com',
        Port => 587,
        User => 'username@gmail.com',
        Password => 'password',
        Hello => 'fayland.org',
    ]
} );

use Email::Simple::Creator; # or other Email::
my $email = Email::Simple->create(
    header => [
        From    => 'username@gmail.com',
        To      => 'to@mail.com',
        Subject => 'Subject title',
    ],
    body => 'Content.',
);

eval { $mailer->send($email) };
die "Error sending email: $@" if $@;

这篇关于如何使用 SMTP 和 Perl 向我的 Gmail 帐户发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆