Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
use strict; use Tk; use Tk::Animation; use Tk::LabEntry; use Tk::Dialog; use Net::SMTP; # main window my $mw = MainWindow->new(-title=>'SendMail Easy'); $mw->maxsize(qw/450 530/); $mw->minsize(qw/450 530/); my $fmain = $mw->Frame( -foreground=>'white',-background => 'ivory2', +-relief=> 'groove', -borderwidth=>2 )->pack( -side => 'top'); my $lbtop = $fmain->Label(-text => "SendMail Easy\n", -foreground => 'black', -background => 'ivory2')->pack(-side=>'top'); # from to my ($from, $to, $subj); my $fr1 = $fmain->Frame( -background => 'gray', -relief=> 'groove', -b +orderwidth=>2 )->pack( -side => 'top'); $fr1->LabEntry(-label=>'From:',-textvariable=>\$from,-labelPack=>[-sid +e=>'left'],-width=>30, -foreground => 'blue',-background => 'white')->pack(); $fr1->LabEntry(-label=>' To :',-textvariable=>\$to,-labelPack=>[-side +=>'left'],-width=>30, -foreground => 'blue',-background => 'white')->pack(); my $txtsubj = $fr1->LabEntry(-label=>'Subj:',-textvariable=>\$subj,-la +belPack=>[-side=>'left'],-width=>30, -foreground => 'blue',-background => 'white')->pack(); # ,-textvariable=>'' # compose my $fr2 = $fmain->Frame( -background => "ivory2", -relief => +'groove', -borderwidth=>2 )->pack( -side => 'top'); my $text = $fr2->Scrolled('Text', -scrollbars => 'osoe', -wrap => 'none', -foreground => 'blue', -background => 'white', -relief=>'flat')->pack(); # send button my $send = $fmain->Button( -text => 'Send eMail', -command => \&sendmail, -relief => 'groove', -foreground => 'black', -background => 'ivory2', )->pack(-ipadx=>10,-ipady=>5); $send->bind('<ButtonRelease-1>' => sub { $mw->messageBox(qw/-icon info -type OK -message/ => "eMail Sent... + \@njoy!"); }); # copyleft my $lbbottom = $mw->Label(-text => "Copyleft to Larry Wall", -foreground => 'black', -background => 'ivory2')->pack(-side=>'bottom'); ## animation my $camelanim = $mw->Animation('-format' => 'gif', -file => Tk->findINC('anim.gif') ); $mw->Label(-image => $camelanim)->pack(-side=>'bottom'); $camelanim->start_animation(200); MainLoop; sub sendmail{ my @message = $text-> get('1.0', 'end'); my $subject = $txtsubj -> get('1.0', 'end'); eval { my $cc = ''; my $smtp = Net::SMTP->new('smtp.server', Debug => 1) or die "connect"; $smtp->mail($from) or die "mail"; $smtp->to($to) or die "to"; # $smtp->to($cc) or die "cc"; $smtp->to($cc) or die "cc"; $smtp->data() or die "data"; $smtp->datasend($subject) or die "subject"; foreach my $line (@message) { $smtp->datasend("$line\n") or die "datasend"; } $smtp->dataend() or die "dataend"; $smtp->quit() or die "quit"; }; if ($@) { die "Message not sent: $@ failed\n"; } }

In reply to Re^2: How to send mail from Perl/Tk Program? by Anonymous Monk
in thread How to send mail from Perl/Tk Program? by mikasue

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (7)
    As of 2018-06-24 17:48 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (126 votes). Check out past polls.