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
| [reply] [d/l] |
| [reply] |
| [reply] |
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
| [reply] [d/l] |
| [reply] |
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
| [reply] |
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__
| [reply] [d/l] |
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.
| [reply] |
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'
| [reply] [d/l] |