Net::SMTP
am 25.07.2006 14:44:04 von Sqrex
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.
Re: Net::SMTP
am 25.07.2006 15:04:27 von Andrzej Adam Filip
"Sqrex" writes:
> 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
Re: Net::SMTP
am 26.07.2006 14:45:06 von Sqrex
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");