Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: How to send mail from Perl/Tk Program?

by mikasue (Friar)
on Apr 10, 2007 at 13:12 UTC ( [id://609130]=note: print w/replies, xml ) Need Help??


in reply to Re: How to send mail from Perl/Tk Program?
in thread How to send mail from Perl/Tk Program?

Oh I see. However when I run the following code:
use strict; use warnings; use Tk; use MIME::Lite; my $MW = MainWindow->new(-background=>'white'); $MW->geometry('400x350+250+100'); my $msg = MIME::Lite->new( From =>'youremail@netzero.com', To =>'youremail@email.com', Subject =>'Helloooooo, USER!', Data =>"This is a test email from my Perl/Tk prog +ram. Enjoy!" ); $MW->Button(-text=>'Test Email to Parent', -background=>'green', -font +=>'Arial 14', -foreground=>'blue', -command=>sub{$msg->send;} )->pack +(-side=>'left', -anchor=>'w', -padx=>'50'); MainLoop;
I get the following error message:

'sendmail' is not recognized as an internal or external command, operable program or batch file.

I thought 'sendmail' was a unix program. I am on a Windows system.

Thanks

Replies are listed 'Best First'.
Re^3: How to send mail from Perl/Tk Program?
by Corion (Patriarch) on Apr 10, 2007 at 13:15 UTC

    Maybe you want to change how messages are sent?

    You will still need a working SMTP server that is willing to accept your email - most likely your ISP provides one for you.

      I thought about this Corion. But I want this to work on other users machines. I dont' want to hardcode my SMTP server in my program and then it doesn't work for another user.

      Any suggestions on making smtp universal to all my users?

        If you don't want to hardcode it, make it configurable for your users. You can also look up the MX record of the domain of the intended recipient and deliver the mail there. But delivering mail is a harder problem than you might think, because of Greylisting and firewalls and other stuff. So I think it's best to leave that up to the user.

Re^3: How to send mail from Perl/Tk Program?
by bibliophile (Prior) on Apr 10, 2007 at 13:18 UTC
    You'll need to change that, then :-) Further down in the doc, there's this section:
    Change how messages are sent ### Do something like this in your 'main': if ($I_DONT_HAVE_SENDMAIL) { MIME::Lite->send('smtp', "smtp.myisp.net", Timeout=>60); } ### Now this will do the right thing: $msg->send; ### will now use Net::SMTP as shown above
    Hope that points you in the right direction :-)

    Update: Wow. Two other answers as I was typing up this one :-D

Re^3: How to send mail from Perl/Tk Program?
by marto (Cardinal) on Apr 10, 2007 at 13:18 UTC
Re^3: How to send mail from Perl/Tk Program?
by memo.garciasir (Acolyte) on Feb 26, 2009 at 16:47 UTC

    And what if I'm looking for a different approach?

    I want a link that do the same as sendto:mymail@server.com. In other words, that call the standard mail program of the user.

    thanks,

    memo.garciasir@gmail.com

      You could put hyperlinks in your Text widgets, that run the mail program, when clicking on the hypertext link. An example, without the actual mailcode....which should be forked off or threaded.
      #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new( -title => "hyperlinks" ); my $t = $mw->Scrolled('Text')->pack; my $tag = "tag000"; foreach (<DATA>) { chomp; my (@items) = split (/(http:\S+)/,$_); foreach (@items) { if (/(http:\S+)/) { $t->insert( 'end', $_, $tag ); $t->tagConfigure( $tag, -foreground => 'blue' ); $t->tagBind( $tag, '<Any-Enter>' => [ \&manipulate_link, $tag, 'raised', +'hand2' ] ); $t->tagBind( $tag, '<Any-Leave>' => [ \&manipulate_link, $tag, 'flat', 'x +term' ] ); $t->tagBind( $tag, '<Button-1>' => [ \&manipulate_link, $tag, 'sunken' ] +); $t->tagBind( $tag, '<ButtonRelease-1>' => [ \&manipulate_link, $tag, 'raised', undef, \&printm +e ] ); $tag++; } else { $t->insert( 'end', $_ ); } } $t->insert( 'end', "\n" ); } MainLoop; sub printme { local ($,) = " "; print "printme:", @_, "\n"; } sub manipulate_link { # manipulate the link as you press the mouse key my ($a) = shift; my ($tag) = shift; my ($relief) = shift; my ($cursor) = shift; my ($after) = shift; # by configuring the relief (to simulate a button press) $a->tagConfigure( $tag, -relief => $relief, -borderwidth => 1 ); # by changing the cursor between hand and xterm $a->configure( -cursor => $cursor ) if ($cursor); # and by scheduling the specified action to run "soon" if ($after) { my ($s) = $a->get( $a->tagRanges($tag) ); $mw->after( 200, [ $after, $a, $s, $tag, @_ ] ) if ($after); } } __DATA__ Hi there. This is text. THis is more text but http://this.is.a/hyperlink in a line. http://this.is.another/hyperlink followed by http://this.is.a.third/hyperlink __END__

      I'm not really a human, but I play one on earth My Petition to the Great Cosmic Conciousness
Re^3: How to send mail from Perl/Tk Program?
by spx2 (Deacon) on Dec 29, 2007 at 12:37 UTC
    on windows there is no sendmail program(unless you're
    on cygwin but probably you're not)
    use Email::Send
    for sending email ,it should work ok.
      But you still need to do some configuration for the SMTP host and maybe the authentication.

      Another possibility is to send mail via the web browser, in the hope that the user already configured the browser to send mail. The downside is that it is necessary to acknowledge the mail outside of the Tk program. For example, this works on my Unix system with seamonkey:

      seamonkey 'mailto:bla@example.com?subject=Subject&body=the%20body%20of +%20the%20mail'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://609130]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-23 06:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found