Click here to get back home

Net::SMTP

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Net::SMTP Sqrex 07-25-2006
---> Re: Net::SMTP Andrzej Adam Fi...07-25-2006
Posted by Sqrex on July 25, 2006, 8:44 am
Please log in for more thread options


Hi.
I`ve got problem with module Net::SMTP. I want to check my SMTP server
is working proparly so i run this script:
#!/usr/bin/perl -w

use Net::SMTP;
         $smtp = Net::SMTP ->        new('100.100.100.100',
                                Hello => 'my_name.ma_domain',
                                Timeout => 10,
                                Debug => 1
                                );


        $smtp->mail('admin@');
$smtp->to('postmaster');
        $smtp->quit;

Debug:
bash-3.00# ./sesja_smtp1.pl
Can't call method "mail" on an undefined value at ./sesja_smtp1.pl line
9.

I want to write to log some memo when my SMTP server don`t answer to
any of this commands.
Is it possible ?

I found something like that in documentation:
"Unless otherwise stated all methods return either a true or false
value, with true meaning that the operation was a success. When a
method states that it returns a value, failure will be returned as
undef or an empty list."
But i don`t know how to use it with if ore while commands.

Thx for help.


Posted by Andrzej Adam Filip on July 25, 2006, 9:04 am
Please log in for more thread options



> Hi.
> I`ve got problem with module Net::SMTP. I want to check my SMTP server
> is working proparly so i run this script:
> #!/usr/bin/perl -w
>
> use Net::SMTP;
>          $smtp = Net::SMTP ->        new('100.100.100.100',
>                                 Hello => 'my_name.ma_domain',
>                                 Timeout => 10,
>                                 Debug => 1
>                                 );
>
>
>         $smtp->mail('admin@');
> $smtp->to('postmaster');
>         $smtp->quit;
>
> Debug:
> bash-3.00# ./sesja_smtp1.pl
> Can't call method "mail" on an undefined value at ./sesja_smtp1.pl line
> 9.


use Net::SMTP;
$smtp = Net::SMTP ->        new('100.100.100.100',
Hello => 'my_name.ma_domain',
Timeout => 10,
Debug => 1
);

if( !defined($smtp)){
# $smtp object have not been created. Problem report is in $@
die $@;
}

> [...]


--
[pl2en: Andrew] Andrzej Adam Filip : anfi@priv.onet.pl : anfi@xl.wp.pl

Posted by Sqrex on July 26, 2006, 8:45 am
Please log in for more thread options


this work but there is another problem. when i receive error message
program ends and i want it to go to next command not to end.

it ends with error:
Net::SMTP: connect: timeout (this is from print $@)
Can't call method "mail" on an undefined value at ./smtp.pl line 11.
end it ends :/


> use Net::SMTP;
> $smtp = Net::SMTP ->        new('100.100.100.100',
> Hello => 'my_name.ma_domain',
> Timeout => 10,
> Debug => 1
> );
>
> if( !defined($smtp)){
> # $smtp object have not been created. Problem report is in $@
> print $@;
> }
$smtp->mail("test\@test.com");


Similar ThreadsPosted
SMTP::new() October 11, 2005, 2:36 am
net smtp help October 24, 2006, 4:02 pm
Net::Telnet and SMTP June 13, 2005, 11:01 am
Question on NET::SMTP new() October 11, 2005, 2:32 am
SMTP: "to" or/and "recipient" question. November 11, 2005, 8:52 am
Net::SMTP Can't get AUTH working... November 2, 2006, 5:39 pm
Installing Net::SMTP as non-root March 19, 2007, 4:03 pm
"Host =>" in the Net::SMTP module August 15, 2007, 8:37 am
RFC: new module Net::SMTP::PostfixExt February 20, 2008, 3:49 pm
Net::SMTP - Unknown callback May 15, 2008, 6:45 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap