Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8085049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:59:24+00:00 2026-06-05T17:59:24+00:00

I have written a perl script to send email using the gmail’s smtp server:

  • 0

I have written a perl script to send email using the gmail’s smtp server: smtp.gmail.com –

use Net::SMTP;

my $smtp = Net::SMTP->new('smtp.gmail.com',
                    Port=> 587,
                    Timeout => 20,
                    Hello=>'user@gmail.com'
                    );
print $smtp->domain,"\n";
$sender = "user@gmail.com";
$password = "mypassword";
$smtp->auth ( $sender, $password ) or die "could not authenticate\n";
$receiver = "user@gmail.com";

$subject = "my custom subject";
$smtp->mail($sender);
$smtp->to($receiver);
$smtp->data();
$smtp->datasend("To: <$reciever> \n");
$smtp->datasend("From: <$sender> \n");
$smtp->datasend("Content-Type: text/html \n");
$smtp->datasend("Subject: $subject");
$smtp->datasend("\n");
$smtp->datasend('the body of the email');
$smtp->dataend();
$smtp->quit();
print "done\n\n";

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.

I am able to connect to the smtp serever of google as I get : ‘mx.google.com’ as the result of :
print $smtp->domain,”\n”;

What is it that I am doing wrong? Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:59:26+00:00Added an answer on June 5, 2026 at 5:59 pm
    use Net::SMTP;
    my $smtp = Net::SMTP->new ....
    

    afaik you need to use an encrypted connection to send via gmail, use Net::SMTP::TLS or Net::SMTP::SSL (with port 465)

    Hello=>'user@gmail.com'
    

    ‘Hello’ is not an email address, put your hostname there instead

    $sender = "user@gmail.com";
    ...
    $receiver = "user@gmail.com";
    

    put these in single quotes

    if you still get “could not authenticate.” make sure you have the modules MIME::Base64 and Authen::SASL installed.

     $smtp->datasend("To: <$reciever> \n");
    

    should be $receiver, not $reciever

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send mail via SMTP in Perl. I have written a
I have written the following Perl script- use HTML::TreeBuilder; my $html = HTML::TreeBuilder->new_from_content(<<END_HTML); <span
I am generating new xml file using perl script but I have small problem,
I have a Perl script that I've written and can compile it using pp
I have written a Perl script, I just want to give it to every
This may be a basic question. I have written a small perl script to
I have written a Perl script that runs as a daily crontab job that
I have written a Perl script that reads some data and generates an OpenOffice
I have a script that's written in perl, and executed as CGI. It works
I have written a Perl script that sends data to clients. It works some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.