As of Jan 29, 2020, the following works.
  1. Turn off 2FA .
  2. on 'https://myaccount.google.com/security?pli=1#connectedapps', look for and allow Less secure app access
  3. on 'https://myaccount.google.com/lesssecureapps', same thing.
  4. use the slightly elaborated perl program:
#!/usr/bin/env perl use strict; use warnings; use autodie; use Data::Dumper; my $gauthtxt= "gauth.txt"; # can define default sending user account +and password ## format: 'user\temail\npasswd\tstring\n' ################################################################ # parse inputs # defaults my %smtp= ( server => 'smtp.gmail.com', port => '587', subject => "tes +ting gmailer.pl", body => "gmail-tester $0: ".localtime() ); # more defaults in gauth.txt if (-e $gauthtxt) { print STDERR "[reading $gauthtxt]\n"; open(my $GA, "<", $gauthtxt); while (<$GA>) { chomp; (/^([a-z]+)\s+(.*)$/) or die "line in $gauthtxt is not pars +eable: $_\n"; $smtp{$1}= $2; } close($GA); } # command line arguments foreach (@ARGV) { foreach my $keyword (qw(user to passwd subject body)) { (/^$keyword= +(.*)/) and $smtp{$keyword}=$1; } } (exists{$smtp{from})) and $smtp{user}=$smtp{from}; ## special equivale +nce ################################################################ # check inputs foreach (qw(user to passwd subject body)) { exists($smtp{$_}) or die "'$_' needs to be in $gauthtxt or spcified +on command line with '$_=...'\n"; } use Email::Valid; (Email::Valid->address($smtp{user})) or die "your own user account $sm +tp{user} is not a valid email address"; (Email::Valid->address($smtp{to})) or die "your recipientd account $sm +tp{to} is not a valid email address"; ################################################################ # send email use Email::Sender::Simple qw(sendmail); use Email::Sender::Transport::SMTPS (); use Email::Simple (); use Email::Simple::Creator (); my $transport = Email::Sender::Transport::SMTPS->new({ host => $smtp{server}, port => $smtp{port}, ssl => "starttls", sasl_username => $smtp{user}, sasl_password => $smtp{passwd}, }); my $email = Email::Simple->create( header => [ To => $smtp{to}, From => $smtp{user}, Subject => $smtp{subject} ], body => $smtp{body}."\n", ); sendmail($email, { transport => $transport }); print "\nemail sent from $smtp{user} to $smtp{to}.\n";

In reply to Re^3: gmail sending in 2020 by iaw4
in thread gmail sending in 2020 by iaw4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.