in reply to Network Unreachable issue while sending email using PERL (gmail)
Hello, first you will need to go into the security setting of your Gmail account and create an "application" password for your script. (This assumes your account is currently set to two-factor auth.) See for example this doc.
Then use Email::Send::SMTP::Gmail:
use strict; use warnings; use Email::Send::SMTP::Gmail; my ( $email, $error ) = Email::Send::SMTP::Gmail->new( -port => 587, -smtp => 'smtp.gmail.com', -login => 'you@gmail.com', -pass => 'passwordyoucreated' ); die "SMTP connection error: $error" if $email == -1; $email->send( -to => 'you@gmail.com', -subject => 'This is the subject', -body => 'This is the message body', ); $email->bye; __END__
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Network Unreachable issue while sending email using PERL (gmail)
by manojsagar (Initiate) on Oct 12, 2017 at 19:16 UTC | |
by 1nickt (Canon) on Oct 12, 2017 at 19:46 UTC |