Aldebaran has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks
I'm trying to follow the development in the alpaca book to create a Perl Daily Briefing, which informs the user on where he or she is going. Previous efforts have focused on making a physical list, which has some use. For getting places, we now are sometimes best directed by online resources. It is that capability I try to peck at in this thread.
In the idiom of the book, we have to pack things away, this time using references and libraries. I've attempted with moderate success to take what I've had in main for creating an html page and herding it into a module.
I use a random text generator that I lifted from perlmonks to generate a file that no one can find without considerable trial and error. I don't think that's too taxing as keystrokes on a phone if need be, in particular with lack of upper case letters. Yet I much prefer to be sent the resulting link, which I attempt to, but so far without success. I think my "big problem" is that I don't understand which host to use when instantiating the smtp object. I peeked on my thunderbird account, and one of my tries was using the exact outgoing smtp for my server. To my (impeachable) knowledge, this does not require username/password identification with thunderbird. Anyways this is what I have:
#!/usr/bin/perl -w use strict; use 5.010; use lib "template_stuff"; use html3; sub rndStr{ join'', @_[ map{ rand @_ } 1 .. shift ] } my $new_name = rndStr( 5, 'a'..'z', 1..9); my $ref_to_name = \$new_name; my $return_page = create_page($ref_to_name); say "page is $return_page"; email_link($return_page); sub email_link{ use strict; use 5.014; use Net::SMTP; use config2; my $link = shift; my $sub_hash = "my_ftp"; my $host = $config{$sub_hash}->{'site'}; say "host is $host"; my $phone = $config{$sub_hash}->{'phone'}; say "phone is $phone"; my $smtp = Net::SMTP->new( Host => $host, Debug => 2); $smtp->mail($ENV{USER}); $smtp->to($phone); $smtp->data; $smtp->datasend("Subject: This is your map link"); $smtp->datasend("$link\n"); $smtp->dataend; $smtp->quit; } __END__
output:
C:\cygwin64\home\Fred\pages2\plot\alpaca>perl alpaca3.pl cipher is 2sq8b word is 2sq8b you are here / a is . .. pdb1.html images pdb2.html pdb3.html pdb4.html jjgg4w5q1.htm +l 1ty83zib 1.html hwr241.html i1f291.html wfi8z1.html r28zr1.html pn8ns1.html j69 +a91.html old num is 0 line 70 says html filename is 2sq8b1.html in create html file your data is 2sq8b1.html remote_dir is 2sq8b1 default is a.txt file down here is 2sq8b1.html new file is 2sq8b1.html page is 2sq8b1.html host is www.1and1.com phone is redacted@txt.att.net Can't call method "mail" on an undefined value at alpaca3.pl line 27.
I get the html page generated and put where I want it : http://merrillpjensen.com/maps/2sq8b1.html, but I can't send the resulting link to my phone, which is where I need it. It "feels like" my smtp object isn't instantiating. I've used 3 different values for $host, all from config2.pm, which follows with redactions:
package config2; use Exporter qw(import); our @EXPORT = qw(%config); our %config = ( my_ftp => { domain => 'www.merrillpjensen.com', username => '...', password => '...', smtp => 'smtp.1and1.com', phone => '...@txt.att.net', site => 'www.1and1.com', }, ); 1;
First I have the question on how to instantiate the smtp object. Beyond that I might ask whether there's an easier way to do all this. Thanks for your comment,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: instantiating an smtp object
by haukex (Archbishop) on Jun 06, 2016 at 07:17 UTC | |
|
Re: instantiating an smtp object
by $h4X4_|=73}{ (Monk) on Jun 06, 2016 at 10:33 UTC | |
by haukex (Archbishop) on Jun 06, 2016 at 11:00 UTC | |
by $h4X4_|=73}{ (Monk) on Jun 06, 2016 at 11:21 UTC | |
by haukex (Archbishop) on Jun 06, 2016 at 11:50 UTC | |
by $h4X4_|=73}{ (Monk) on Jun 06, 2016 at 14:27 UTC | |
| |
by Aldebaran (Curate) on Jun 07, 2016 at 07:57 UTC | |
by $h4X4_|=73}{ (Monk) on Jun 07, 2016 at 09:04 UTC | |
by Aldebaran (Curate) on Jun 09, 2016 at 03:49 UTC |