Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

How do I send email through GMail?

by stevieb (Canon)
on Jan 17, 2023 at 06:16 UTC ( [id://11149627]=perlmeditation: print w/replies, xml ) Need Help??

Every few years I try to update this post so that people are aware.

Question is how to send email through GMail, or otherwise a Google Account.

It's still easy, but different. The instructions can be found in the above link through your own research. It can be done.

I want to keep this knowledge alive. When I have difficulty and find a solution, I want others to know how I overcame it. We should all be able to send mail or text messages through our Google accounts.

use warnings; use strict; use Net::SMTP; my $smtp = Net::SMTP->new( 'smtp.gmail.com', Hello => 'local.example.com', Timeout => 30, Debug => 1, SSL => 1, Port => 465 ); # Password here is an app password. Need to enable 2FA on Google # account to generate one $smtp->auth('steve.bertrand@gmail.com', '*app_password*') or die; $smtp->mail('steve.bertrand@gmail.com'); $smtp->to('steve.bertrand@gmail.com'); $smtp->data(); $smtp->datasend("hey!\n"); $smtp->quit();

The above is copy and pastable working code. I'm all in with no obfu with my real email address. I'm good with seeing how the cards fall.

Replies are listed 'Best First'.
Re: How do I send email through GMail?
by jdporter (Paladin) on Jan 17, 2023 at 15:58 UTC
Re: How do I send email through GMail?
by Cody Fendant (Hermit) on Nov 12, 2023 at 00:16 UTC

    Worth noting that when Google gives you an app password it's presented in the form abcd defg hijk lmno, that is, 16 chars with spaces every 4. You should remove the spaces.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://11149627]
Approved by Arunbear
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-03-29 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found