| 1 | package Mail::OpenRelay::Simple; | ||||||||||||||||||||||
| 2 | |||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.008; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | 1 | ▶ | use base qw(Class::Accessor::Fast); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | 1 | ▶ | use Carp; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 8 | 1 | ▶ | use Net::Telnet; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 9 | |||||||||||||||||||||||
| 10 | 1 | our $VERSION = '0.02'; | |||||||||||||||||||||
| 11 | 1 | $VERSION = eval $VERSION; | |||||||||||||||||||||
| 12 | |||||||||||||||||||||||
| 13 | 1 | __PACKAGE__->mk_accessors( qw(host port timeout from_email rcpt_email banner debug)); | |||||||||||||||||||||
| 14 | |||||||||||||||||||||||
| 15 | 1 | $| = 1; | |||||||||||||||||||||
| 16 | |||||||||||||||||||||||
| 17 | 1 | ▶ | sub check { | ||||||||||||||||||||
|
Subroutine
check: called CC=24 SCAR=54.2
Pod
documented
| |||||||||||||||||||||||
| 18 | |||||||||||||||||||||||
| 19 | 1 | my $self = shift; | |||||||||||||||||||||
| 20 | 1 | my $host = $self->host; | |||||||||||||||||||||
| 21 | 1 | my $port = $self->port; | |||||||||||||||||||||
| 22 | 1 | my $timeout = $self->timeout; | |||||||||||||||||||||
| 23 | 1 | my $from_email = $self->from_email; | |||||||||||||||||||||
| 24 | 1 | my $rcpt_email = $self->rcpt_email; | |||||||||||||||||||||
| 25 | 1 | my $banner = $self->banner; | |||||||||||||||||||||
| 26 | 1 | my $debug = $self->debug; | |||||||||||||||||||||
| 27 | |||||||||||||||||||||||
| 28 | 1 | ▶ | $banner = $banner ? $banner : 0; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 29 | 1 | ▶ | $debug = $debug ? $debug : 0; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 30 | 1 | ▶ | $from_email = $from_email ? $from_email : "test\@foobar.com"; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 31 | 1 | ▶ | $rcpt_email = $rcpt_email ? $rcpt_email : "test\@foobar.com"; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 32 | |||||||||||||||||||||||
| 33 | 1 | ▶ | print ". Try to connect to $host...\n" if $debug == 2; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 34 | |||||||||||||||||||||||
| 35 | 1 | ▶ | my $t = new Net::Telnet( | ||||||||||||||||||||
|
Condition50%2/4
$port || '25'
$timeout || '8'
MC/DC0%0/1
$port || '25'
$port
MC/DC0%0/1
$timeout || '8'
$timeout
Truth table50%1/2
A
A= $port
Truth table50%1/2
A
A= $timeout
| |||||||||||||||||||||||
| 36 | Host => $host, | ||||||||||||||||||||||
| 37 | Port => $port || '25', | ||||||||||||||||||||||
| 38 | Timeout => $timeout || '8', | ||||||||||||||||||||||
| 39 | Errmode => "return" | ||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||
| 41 | |||||||||||||||||||||||
| 42 | 1 | ▶ | if ($t){ | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 43 | 0 | my $match = $t->getline; | |||||||||||||||||||||
| 44 | |||||||||||||||||||||||
| 45 | 0 | ▶ | if ($match){ | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 46 | |||||||||||||||||||||||
| 47 | 0 | my $Banner = $match; | |||||||||||||||||||||
| 48 | 0 | chomp $Banner; for ($Banner) { s/^220\s//; } | |||||||||||||||||||||
| 49 | |||||||||||||||||||||||
| 50 | 0 | ▶ | if ($match =~ m/^220/){ | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 51 | |||||||||||||||||||||||
| 52 | 0 | ▶ | print ". HELO foo\n" if $debug == 1; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 53 | 0 | $t->print("HELO foo"); | |||||||||||||||||||||
| 54 | |||||||||||||||||||||||
| 55 | 0 | $match = $t->getline; | |||||||||||||||||||||
| 56 | 0 | ▶ | if ($match){ | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 57 | 0 | ▶ | if ($match =~ /^250/){ | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 58 | |||||||||||||||||||||||
| 59 | 0 | ▶ | print ". MAIL FROM:<$from_email>\n" if $debug == 1; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 60 | 0 | $t->print("MAIL FROM:<$from_email>"); | |||||||||||||||||||||
| 61 | |||||||||||||||||||||||
| 62 | 0 | $match = $t->getline; | |||||||||||||||||||||
| 63 | |||||||||||||||||||||||
| 64 | 0 | ▶ | if ($match){ | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 65 | 0 | ▶ | if ($match =~ /^250/){ | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 66 | |||||||||||||||||||||||
| 67 | 0 | ▶ | print ". RCPT TO:<$rcpt_email>\n" if $debug == 1; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 68 | 0 | $t->print("RCPT TO:<$rcpt_email>"); | |||||||||||||||||||||
| 69 | |||||||||||||||||||||||
| 70 | 0 | $match = $t->getline; | |||||||||||||||||||||
| 71 | |||||||||||||||||||||||
| 72 | 0 | ▶ | if ($match){ | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 73 | 0 | ▶ | if ($match =~ /^250/){ | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 74 | 0 | ▶ | print "$Banner\n" if $banner == 1; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 75 | 0 | return 1; | |||||||||||||||||||||
| 76 | } else { | ||||||||||||||||||||||
| 77 | 0 | return 0; | |||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||
| 79 | } else { | ||||||||||||||||||||||
| 80 | 0 | ▶ | print ". can't send email with $host!\n" if $debug == 1; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||
| 88 | 0 | $t->close; | |||||||||||||||||||||
| 89 | } else { | ||||||||||||||||||||||
| 90 | 1 | ▶ | print ". can't connect to host $host on port $port\n" if $debug == 1; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||
| 92 | |||||||||||||||||||||||
| 93 | 1 | return; | |||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||
| 95 | |||||||||||||||||||||||
| 96 | 1 | 1; | |||||||||||||||||||||
| 97 | __END__ | ||||||||||||||||||||||