For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > November 2004 > sending email thru Net::SMTP in TK









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author sending email thru Net::SMTP in TK
mike

2004-11-23, 3:56 am

hi

i tried to send email in my tk application using Net::SMTP
my $smtp = Net::SMTP->new('10.10.10.10',Hello=>'server', Timeout=>60);
# connect to an SMTP server
$smtp->mail("TEST"); # use the sender's address here
$smtp->to(@to);
$smtp->cc(@cc);
$smtp->data(); # Start the mail
$smtp->datasend("To:@to\n");
$smtp->datasend("Subject:Test\n");
$smtp->datasend("cc:@cc\n");
$smtp->datasend("\n");
$smtp->datasend("A simple test.");
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP connection

but i didn't work. There's no email sent
When i try it in a command line version, it works.
Does tk have any restriction on sending email through Net::SMTP
package?
thanks
zentara

2004-11-23, 3:57 pm

On 22 Nov 2004 20:35:42 -0800, s99999999s2003@yahoo.com (mike) wrote:

>hi
>
>i tried to send email in my tk application using Net::SMTP
>my $smtp = Net::SMTP->new('10.10.10.10',Hello=>'server', Timeout=>60);
># connect to an SMTP server
>$smtp->mail("TEST"); # use the sender's address here
>$smtp->to(@to);
>$smtp->cc(@cc);
>$smtp->data(); # Start the mail
>$smtp->datasend("To:@to\n");
>$smtp->datasend("Subject:Test\n");
>$smtp->datasend("cc:@cc\n");
>$smtp->datasend("\n");
>$smtp->datasend("A simple test.");
>$smtp->dataend(); # Finish sending the mail
>$smtp->quit; # Close the SMTP connection
>
>but i didn't work. There's no email sent
>When i try it in a command line version, it works.
>Does tk have any restriction on sending email through Net::SMTP
>package?
>thanks


It should work with no problem from Tk. Maybe you don't
have it setup right? You don't show any Tk code.


--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
ikepgh

2004-11-24, 3:57 am

s99999999s2003@yahoo.com (mike) wrote in message news:<dfd17ef4.0411222035.375320c@posting.google.com>...
> hi
>
> i tried to send email in my tk application using Net::SMTP
> my $smtp = Net::SMTP->new('10.10.10.10',Hello=>'server', Timeout=>60);
> # connect to an SMTP server
> $smtp->mail("TEST"); # use the sender's address here
> $smtp->to(@to);
> $smtp->cc(@cc);
> $smtp->data(); # Start the mail
> $smtp->datasend("To:@to\n");
> $smtp->datasend("Subject:Test\n");
> $smtp->datasend("cc:@cc\n");
> $smtp->datasend("\n");
> $smtp->datasend("A simple test.");
> $smtp->dataend(); # Finish sending the mail
> $smtp->quit; # Close the SMTP connection
>
> but i didn't work. There's no email sent
> When i try it in a command line version, it works.
> Does tk have any restriction on sending email through Net::SMTP
> package?
> thanks



Please take a look at my Perl/TK email program:

https://sourceforge.net/projects/ezemail/

This should give you a pretty good idea of how to get it to send w/
TK. Specifically, look in "sub doSmtp" routine. While we're on the
subject, I have another question for all you Perl/TK gurus:

How can I capture the textvariable in an entry box for the sole
purpose of sending the email to multiple recipients? I know this
basic question has been asked numerous times, but I have searched over
600 posts on NET::SMTP (honest!) over the past two days and have not
found a suitable answer as it relates to Perl/TK. My code will send
it to one email correctly, but will not send it to anyone in the "CC"
line if multiple recipients are entered (they are seperated by
commas).

Here's the relevant code:

my $entry2 = $frame2 -> Entry(-textvariable => \$ccmail,
-width => 46,
-background => 'white')
->pack(-side => 'left',
-pady => 3);


etc....

$smtp -> cc($ccmail);

etc....

$smtp -> datasend("CC: $ccmail\n");

etc....

Thanks in advance,
ikepgh
zentara

2004-11-24, 4:00 pm

On 23 Nov 2004 19:25:26 -0800, ike@ezcyberspace.com (ikepgh) wrote:

[color=darkred]
>ikepgh wrote
>How can I capture the textvariable in an entry box for the sole
>purpose of sending the email to multiple recipients? I know this
>basic question has been asked numerous times, but I have searched over
>600 posts on NET::SMTP (honest!) over the past two days and have not
>found a suitable answer as it relates to Perl/TK. My code will send
>it to one email correctly, but will not send it to anyone in the "CC"
>line if multiple recipients are entered (they are seperated by
>commas).


>Here's the relevant code:
>my $entry2 = $frame2 -> Entry(-textvariable => \$ccmail,
> -width => 46,
> -background => 'white')
> ->pack(-side => 'left',
> -pady => 3);
>
>$smtp -> cc($ccmail);
>$smtp -> datasend("CC: $ccmail\n");


I've seen this question asked in a non-Tk setting and the
answer was To and CC takes arrays. You are feeding it a
comma-separated string...which is not an array.

So try something like:
my @cc = split ',' , $ccmail;
$smtp -> cc(@cc);




--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
ikepgh

2004-11-25, 8:59 am

zentara <zentara@highstream.net> wrote in message news:<9i39q09qknoclp0jp7hrd3iv2pjsp9agu0@4ax.com>...
> On 23 Nov 2004 19:25:26 -0800, ike@ezcyberspace.com (ikepgh) wrote:
>
>
>
>
> I've seen this question asked in a non-Tk setting and the
> answer was To and CC takes arrays. You are feeding it a
> comma-separated string...which is not an array.
>
> So try something like:
> my @cc = split ',' , $ccmail;
> $smtp -> cc(@cc);



Sheeesh...That was almost too easy! Thank you so much.

ikepgh
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com