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.
| [reply] |
| [reply] |
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.
| [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] |