RamyaArulkumar has asked for the wisdom of the Perl Monks concerning the following question:

Hi Friends,

I have tried to send an email through the below script.

#!/usr/bin/perl -w use Net::SMTP::SSL; # Send away! &send_mail(); sub send_mail { #my $to = $_[0];#my $subject = $_[1];#my $body = $_[2]; my $to = 'TOADDRESS'; my $subject = "TESTFROMME"; my $body = "Welcome"; my $from = 'FROMADDRESS'; my $password = 'mypassword'; my $smtp; if (not $smtp = Net::SMTP::SSL->new('smtp.gmail.com', Port => 465, Debug => 1)) { die "Could not connect to server\n" +; } $smtp->auth($from, $password) || die "Authentication failed!\n"; $smtp->mail($from . "\n"); my @recepients = split(/,/, $to); foreach my $recp (@recepients) { $smtp->to($recp . "\n"); } $smtp->data(); $smtp->datasend("From: " . $from . "\n"); $smtp->datasend("To: " . $to . "\n"); $smtp->datasend("Subject: " . $subject . "\n"); $smtp->datasend("\n"); $smtp->datasend($body . "\n"); $smtp->dataend(); $smtp->quit; }

But i got the below error

Net::SMTP::SSL>>> Net::SMTP::SSL(1.03) Net::SMTP::SSL>>> IO::Socket::SSL(2.016) Net::SMTP::SSL>>> IO::Socket::IP(0.37) Net::SMTP::SSL>>> IO::Socket(1.38) Net::SMTP::SSL>>> IO::Handle(1.35) Net::SMTP::SSL>>> Exporter(5.71) Net::SMTP::SSL>>> Net::Cmd(2.30) Net::SMTP::SSL=GLOB(0x134bcdc)<<< 220 smtp.gmail.com ESMTP e20sm493149 +79pfd.4 - gsmtp Net::SMTP::SSL=GLOB(0x134bcdc)>>> EHLO localhost.localdomain Net::SMTP::SSL=GLOB(0x134bcdc)<<< 250-smtp.gmail.com at your service, +[203.129.2 55.76] Net::SMTP::SSL=GLOB(0x134bcdc)<<< 250-SIZE 35882577 Net::SMTP::SSL=GLOB(0x134bcdc)<<< 250-8BITMIME Net::SMTP::SSL=GLOB(0x134bcdc)<<< 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-C +LIENTTOKEN OAUTHBEARER XOAUTH Net::SMTP::SSL=GLOB(0x134bcdc)<<< 250-ENHANCEDSTATUSCODES Net::SMTP::SSL=GLOB(0x134bcdc)<<< 250-PIPELINING Net::SMTP::SSL=GLOB(0x134bcdc)<<< 250-CHUNKING Net::SMTP::SSL=GLOB(0x134bcdc)<<< 250 SMTPUTF8 Net::SMTP::SSL=GLOB(0x134bcdc)>>> AUTH LOGIN Net::SMTP::SSL=GLOB(0x134bcdc)<<< 334 VXNlcm5hbWU6 Net::SMTP::SSL=GLOB(0x134bcdc)>>> cmFteWEuYUBqb3V2ZS5pbg== Net::SMTP::SSL=GLOB(0x134bcdc)<<< 334 UGFzc3dvcmQ6 Net::SMTP::SSL=GLOB(0x134bcdc)>>> ZXN0aGVycm9iZXJ0 Net::SMTP::SSL=GLOB(0x134bcdc)<<< 534-5.7.14 <https://accounts.google. +com/Contin ueSignIn?sarp=1&scc=1&plt=AKgnsbsk2 Net::SMTP::SSL=GLOB(0x134bcdc)<<< 534-5.7.14 rFysZ-xVTolj9OFNHoALIAkOT +O1T3W7FqG_ uoPY73iEDFLgtATuuP9vHJuUjLdXNUVABOQ Net::SMTP::SSL=GLOB(0x134bcdc)<<< 534-5.7.14 zRyXVzlScbYYAkPtTA3v5QqWV +Gw-JcKq_CG bCgpRyY6RYjHvSPuOWgpUsXKP9YLV5mIggl Net::SMTP::SSL=GLOB(0x134bcdc)<<< 534-5.7.14 6Sfg4cpnyOn4WrQpSA9sp3M5h +FKcNtZF1pE taJiLR2UX4CxeEF5504jg98Z5BjeLU78WJ8 Net::SMTP::SSL=GLOB(0x134bcdc)<<< 534-5.7.14 B2e3WQdUvDH9l8YRXhV40QvO3 +A_Q> Pleas e log in via your web browser and Net::SMTP::SSL=GLOB(0x134bcdc)<<< 534-5.7.14 then try again. Net::SMTP::SSL=GLOB(0x134bcdc)<<< 534-5.7.14 Learn more at Net::SMTP::SSL=GLOB(0x134bcdc)<<< 534 5.7.14 https://support.google.c +om/mail/an swer/78754 e20sm49314979pfd.4 - gsmtp Authentication failed!

Kindly advice me.

Thanks in Advance,

Esther

Replies are listed 'Best First'.
Re: Mail Sending Issue
by Corion (Patriarch) on Mar 02, 2016 at 07:46 UTC

    Have you read the text in the reply? What happened when you followed the instructions there?

    https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbsk2r +FysZ-xVTolj9OFNHoALIAkOTO1T3W7FqG_uoPY73iEDFLgtATuuP9vHJuUjLdXNUVABOQ +zRyXVzlScbYYAkPtTA3v5QqWVGw-JcKq_CGbCgpRyY6RYjHvSPuOWgpUsXKP9YLV5mIgg +l6Sfg4cpnyOn4WrQpSA9sp3M5hFKcNtZF1pEtaJiLR2UX4CxeEF5504jg98Z5BjeLU78W +J8B2e3WQdUvDH9l8YRXhV40QvO3 Please log in via your web browser and then try again. Learn more at https://support.google.com/mail/answer/78754 e20sm49314979pfd.4

    Maybe you want to read the instructions or "Learn more" at the given URL.

Re: Mail Sending Issue
by poj (Abbot) on Mar 02, 2016 at 08:30 UTC

      Already Tried.

      use strict; use warnings; use Email::Send::SMTP::Gmail; my $mail=Email::Send::SMTP::Gmail->new( -smtp=>'smtp.gmail.com', -layer=>'ssl', -port=>465, -verbose => '1' -login=>'mylogin' -pass=>'mypassword'); $mail->send(-to=>'toaddress', -subject=>'Hello!', -verbose=>'1', -body=>'Just testing it', -attachments=>''); $mail->bye;

      But Got the Below Error

      Argument "login" isn't numeric in subtraction (-) at Mail.pl line 6. Argument "pass" isn't numeric in subtraction (-) at Mail.pl line 6. Argument "ramya.a@jouve.in" isn't numeric in subtraction (-) at Mail.p +l line 6. auth(username, password) at C:/Perl/site/lib/Net/SMTPS.pm line 165.

        Try again with added commas

           -verbose => '1',
        #                 ^ here
          -login=>'mylogin',
        #                  ^ here
        
        poj