Commit | Line | Data |
---|---|---|
21c4e167 H |
1 | #!/usr/bin/env perl |
2 | use strict; | |
3 | use warnings; | |
4 | use IO::Socket::INET; | |
5 | ||
6 | $netdns = eval 'use Net::DNS'; | |
7 | if($netdns) use Net::DNS; | |
8 | ||
9 | my $from='harvie@harvie.cz'; | |
10 | my $rcpt='harvie@email.cz'; | |
11 | my $subj='Subj3ct'; | |
12 | my $mesg='H3ll0 Dolly!'; | |
13 | $rcpt='martin.mudrunka@t-email.cz'; $mesg = qx { bash -c 'links -dump http://www.gymjosefska.cz/studium/suplovani/suplobec.htm | grep -i "3.AG\\|suplov.n."' }; | |
14 | ||
15 | my @rcpts = split('@', $rcpt); | |
16 | ||
17 | ||
18 | if($netdns) { | |
19 | my $preference = -1; | |
20 | my $xchg; | |
21 | foreach(mx($rcpts[1])) { | |
22 | if($_->preference > $preference) { | |
23 | $preference = $_->preference; | |
24 | $xchg = $_->exchange; | |
25 | } | |
26 | } | |
27 | } else { | |
28 | #get mx without Net::DNS | |
29 | foreach(split("\n", qx{ bash -c "host -t mx email.cz | cut -d ' ' -f 7" })) { | |
30 | chop($_); | |
31 | print "mx: $_\n"; | |
32 | } | |
33 | } | |
34 | ||
35 | my $data = <<END | |
36 | HELO $rcpts[1] | |
37 | MAIL FROM:<$from> | |
38 | RCPT TO:<$rcpt> | |
39 | DATA | |
40 | From: <$from> | |
41 | To: <$rcpt> | |
42 | Subject: $subj | |
43 | ||
44 | $mesg\r\n.\r\nQUIT | |
45 | END | |
46 | ; | |
47 | ||
48 | my $sock = IO::Socket::INET->new(PeerAddr => $xchg, PeerPort => '25'); | |
49 | print "SRV: ".<$sock>; | |
50 | print $data; | |
51 | print $sock $data; | |
52 | while(<$sock>) { | |
53 | print "SRV: ".$_; | |
54 | STDOUT->flush; | |
55 | } | |
56 | ||
57 | $sock->close; | |
58 |