Update: I would not use Net::SMTP. please refer to Re: instantiating an smtp object post of Email namespace's if you trust them or just write your own Sendmail.

maybe try this. use Carp; to croak" $@"; the errors.

#!/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 Carp; 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"; if (exists $ENV{USER} && $ENV{USER}) { eval q^ use Net::SMTP; my $smtp = Net::SMTP->new(Host => $host, Debug => 2) or croak "Unable to connect to '$host'. $!"; $smtp->mail($ENV{USER}); $smtp->to($phone); $smtp->data(); $smtp->datasend("From: $ENV{USER}\n"); $smtp->datasend("Subject: This is your map link\n"); $smtp->datasend("\n"); $smtp->datasend($link); $smtp->dataend(); $smtp->quit(); ^; croak "Net::SMTP fatal error: $@" if $@; } else { say '$ENV{USER} does not exists or is not defined.'; } } __END__
updated: use Carp; Carp


In reply to Re: instantiating an smtp object by $h4X4_|=73}{
in thread instantiating an smtp object by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.