morgon has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I cannot seem to figure out how to send mail via gmail using Net::SMTP (that's what you're supposed to use right?).
Here is what I try:
It all looks very silly to me and (even worse) it does not work.use strict; use Net::SMTP; my $from = 'somebody@gmail.com'; my $full_name = "Some Body"; my $pw = "my_password"; my $to = 'someone@somewhere.com'; my $smtp = Net::SMTP->new('smtp.gmail.com', Port=> 587, User => $from, Password => $pw ); $smtp->mail($from); $smtp->recipient($to); $smtp->data(); $smtp->datasend("To: $to"); $smtp->datasend("From: $full_name\n"); $smtp->datasend("Content-Type: text/plain \n"); $smtp->datasend("Subject: A Test Mail"); $smtp->datasend("\n"); $smtp->datasend("This is a test mail body"); $smtp->datasend("\n"); $smtp->dataend(); $smtp->quit();
I do not get an error, but no mail seems to get sent.
So my question: How do you send mail via gmail using perl in the year 2020?
Many thanks!
EDIT:
Why do code-blocks look so bad now?
EDIT2: Because copying the code introduced a lot of white space - fixed that.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: gmail and Net::SMTP
by pryrt (Abbot) on Mar 12, 2020 at 19:18 UTC | |
by morgon (Priest) on Mar 12, 2020 at 20:05 UTC | |
by hippo (Bishop) on Mar 13, 2020 at 09:17 UTC | |
Re: gmail and Net::SMTP
by bliako (Monsignor) on Mar 12, 2020 at 21:18 UTC |
Back to
Seekers of Perl Wisdom