Mail-Address Check.pl: Unterschied zwischen den Versionen

Aus Si:Wiki von Siegrist SystemLösungen - Informatik und Rezepte
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: «<syntaxhighlight lang="perl"> #!/usr/bin/perl use strict; use IO::Socket::INET; sub TRUE { 1; } sub FALSE { 0; } if ( ($#ARGV + 1) < 3 ) { print "Usage: $0…»)
 
 
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 2: Zeile 2:
  
 
#!/usr/bin/perl
 
#!/usr/bin/perl
 +
 +
# Copyright (c) 2015 by Peter_Siegrist(SystemLoesungen)  (PSS @ ZweierNet.ch)
 +
# pss.ZweierNet.ch
 +
#
 +
# This program is absolutely free software.
 +
# Use it as you like but don't point the finger of blame to me.
 +
#
  
 
use strict;
 
use strict;
Zeile 10: Zeile 17:
  
 
if ( ($#ARGV + 1) < 3 ) {
 
if ( ($#ARGV + 1) < 3 ) {
print "Usage: $0   \n";
+
print "Usage: $0 < mailserver-to-check-for > < port-on-server-25-or-587 > < email-adress-to-check > \n";
 
exit;
 
exit;
 
}
 
}
Zeile 32: Zeile 39:
 
print $SOCKET "RCPT TO: $address_to_check\n";
 
print $SOCKET "RCPT TO: $address_to_check\n";
 
$answer = <$SOCKET>;
 
$answer = <$SOCKET>;
print "Answer: $answer\n";
+
#print "Answer: $answer\n";
  
 
close $SOCKET;
 
close $SOCKET;

Aktuelle Version vom 26. Dezember 2015, 03:04 Uhr

#!/usr/bin/perl
 
# Copyright (c) 2015 by Peter_Siegrist(SystemLoesungen)  (PSS @ ZweierNet.ch)
# pss.ZweierNet.ch
#
# This program is absolutely free software. 
# Use it as you like but don't point the finger of blame to me.
#
 
use strict;
use IO::Socket::INET;
 
sub TRUE { 1; }
sub FALSE { 0; }
 
if ( ($#ARGV + 1) < 3 ) {
	print "Usage: $0  < mailserver-to-check-for > < port-on-server-25-or-587 > < email-adress-to-check > \n";
	exit;
}
my $server = shift;
my $port = shift;
my $address_to_check = shift;
my $answer = "";
my $SOCKET = IO::Socket::INET->new(
        PeerAddr => "$server",
        PeerPort => "$port",
        Proto   => 'tcp') || die "Error in create socket!: $!";
 
<$SOCKET>;
print $SOCKET "HELO xy\n";
<$SOCKET>;
print $SOCKET "RSET\n";
<$SOCKET>;
print $SOCKET "MAIL FROM: addrecheck\@example.org\n";
<$SOCKET>;
$answer = "";
print $SOCKET "RCPT TO: $address_to_check\n";
$answer = <$SOCKET>;
#print "Answer: $answer\n";
 
close $SOCKET;
 
exit FALSE if $answer !~ m/\s+ok/i;
exit TRUE;