title: (perl Net::SMTP) authentication failure using gmail smtp server
body: <p>I have written a perl script to send email using the gmail's smtp server: smtp.gmail.com -</p>
  
  <pre><code>use Net::SMTP;
  
  my $smtp = Net::SMTP-&gt;new('smtp.gmail.com',
                      Port=&gt; 587,
                      Timeout =&gt; 20,
                      Hello=&gt;'user@gmail.com'
                      );
  print $smtp-&gt;domain,"\n";
  $sender = "user@gmail.com";
  $password = "mypassword";
  $smtp-&gt;auth ( $sender, $password ) or die "could not authenticate\n";
  $receiver = "user@gmail.com";
  
  $subject = "my custom subject";
  $smtp-&gt;mail($sender);
  $smtp-&gt;to($receiver);
  $smtp-&gt;data();
  $smtp-&gt;datasend("To: &lt;$reciever&gt; \n");
  $smtp-&gt;datasend("From: &lt;$sender&gt; \n");
  $smtp-&gt;datasend("Content-Type: text/html \n");
  $smtp-&gt;datasend("Subject: $subject");
  $smtp-&gt;datasend("\n");
  $smtp-&gt;datasend('the body of the email');
  $smtp-&gt;dataend();
  $smtp-&gt;quit();
  print "done\n\n";
  </code></pre>
  
  <p>For 'user', I have my gmail username and for 'mypassword' I have the password. But when I run this code it stops at the auth itself giving : could not authenticate.</p>
  
  <p>I am able to connect to the smtp serever of google as I get : 'mx.google.com' as the result of :<br>
  print $smtp->domain,"\n";</p>
  
  <p>What is it that I am doing wrong? Please help.</p>