-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueuesmtp.pl
More file actions
33 lines (30 loc) · 931 Bytes
/
queuesmtp.pl
File metadata and controls
33 lines (30 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/perl -w
use strict;
use Net::SMTP;
use Netscaler::KAS;
sub smtp_queue_probe
{
if(scalar(@_) < 3)
{
return (1,"Invalid number of arguments");
}
my $smtp;
my ($from_addr, $to_addr) = split /:/, $_[2];
$smtp=Net::SMTP->new($_[0].":".$_[1], Timeout=>$_[3])
or return (1,"Unable to connect to server - $!");
$smtp->mail($from_addr)
or return(2,"MAIL FROM rejected - ".$smtp->message());
$smtp->recipient($to_addr)
or return(3,"RCPT TO rejected - ".$smtp->message());
$smtp->data
or return(4,"DATA rejected - ".$smtp->message());
$smtp->datasend("To: $to_addr\n");
$smtp->datasend("From: $from_addr\n");
$smtp->datasend("\n");
$smtp->datasend("This is a test email from a Netscaler probe\n");
$smtp->dataend
or return(5,"DATA error - ".$smtp->message());
$smtp->quit;
return 0;
}
probe(\&smtp_queue_probe);