MIME::Lite - 无法发送邮件 [smtp.gmail.com 不支持 SMTP auth() 命令]

MIME::Lite - Cannot send mail [SMTP auth() command not supported on smtp.gmail.com]

    use MIME::Lite;
    use warnings;
    use MIME::Base64;
    use Authen::SASL;
    use MIME::Lite;
    use MIME::Base64;
    use Authen::SASL;
    use warnings;
    use Net::SMTP::TLS;
    use Data::Dumper;
    use MIME::Lite;
    $to = 'pratapchintha@gmail.com';
    $cc = 'pratapchintha@gmail.com';
    $from = 'pratapchintha@gmail.com';
    $subject = 'Test Email';
$message = 'email';

$msg = MIME::Lite->new(
             From     => $from,
             To       => $to,
             Cc       => $cc,
             Subject  => $subject,
             Type     => 'multipart/mixed'
             );

 $msg->attach(Type         => 'text',
         Data         => $message
        );

$msg->attach(Type        => 'image/gif',
         Path        => 'C:\Users\chintpra\Desktop\excel\Feb_4.xls',
         Filename    => 'logo.gif',
         Disposition => 'attachment'
        );              
$msg->send('smtp', "smtp.gmail.com", AuthUser=>"$from",          AuthPass=>"*******",Debug=>1);
   print "Email Sent Successfully\n";

输出

     MIME::Lite::SMTP>>> MIME::Lite::SMTP
     MIME::Lite::SMTP>>>   Net::SMTP(3.05)
     MIME::Lite::SMTP>>>     Net::Cmd(3.05)
     MIME::Lite::SMTP>>>       Exporter(5.67)
     MIME::Lite::SMTP>>>     IO::Socket::INET(1.33)
     MIME::Lite::SMTP>>>       IO::Socket(1.34)
     MIME::Lite::SMTP>>>         IO::Handle(1.33)
     MIME::Lite::SMTP=GLOB(0x2c030e0)<<< 220 mx.google.com ESMTP  gj9sm3721288pbc.32 - gsmtp
     MIME::Lite::SMTP=GLOB(0x2c030e0)>>> EHLO localhost.localdomain
     MIME::Lite::SMTP=GLOB(0x2c030e0)<<< 250-mx.google.com at your service,  [123.63.237.69]
     MIME::Lite::SMTP=GLOB(0x2c030e0)<<< 250-SIZE 35882577
     MIME::Lite::SMTP=GLOB(0x2c030e0)<<< 250-8BITMIME`enter code here`
     MIME::Lite::SMTP=GLOB(0x2c030e0)<<< 250-STARTTLS
     MIME::Lite::SMTP=GLOB(0x2c030e0)<<< 250-ENHANCEDSTATUSCODES
     MIME::Lite::SMTP=GLOB(0x2c030e0)<<< 250-PIPELINING
     MIME::Lite::SMTP=GLOB(0x2c030e0)<<< 250-CHUNKING
     MIME::Lite::SMTP=GLOB(0x2c030e0)<<< 250 SMTPUTF8
     SMTP auth() command not supported on smtp.gmail.com

谁能告诉我出了什么问题以及如何解决?

MIME::Lite - 通过 Gmail 发送 [SMTPS - Net::SMTP 3.05]

警告MIME::Lite 过滤传递给 Net::SMTP 的参数 - 参见

AFAIK Gmail 提供 SMTP AUTH overecypted 连接
(通过 SMTPS 连接或在 STARTTLS SMTP 命令之后)。

对于 Net::SMTP 3.05,您可以使用 SMTPS 作为一个干净的修复程序。
Net::SMTP 3.0 以下的版本不支持 SMTPS。
[警告:参见]

$msg->send('smtp', "smtp.gmail.com", 
  SSL=>1,
  AuthUser=>"$from",  AuthPass=>"*******",
  Debug=>1);

Net::SMTP 3.05 documentation

MIME::Lite 已弃用。

这对我有用,使用首选 Email::Sender:

use strict;
use warnings;

use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTPS ();
use Email::Simple ();
use Email::Simple::Creator ();

my $smtpserver = 'server';
my $smtpport = 587;
my $smtpuser   = 'username';
my $smtppassword = 'password';

my $transport = Email::Sender::Transport::SMTPS->new({
  host => $smtpserver,
  port => $smtpport,
  ssl => "starttls",
  sasl_username => $smtpuser,
  sasl_password => $smtppassword,
});

my $email = Email::Simple->create(
  header => [
    To      => 'mymail@gmail.com',
    From    => 'sender@example.com',
    Subject => 'Hi!',
  ],
  body => "This is my message\n",
);

sendmail($email, { transport => $transport });