Added some hexadecimal display capabilities to aclox ascii clock
[mirrors/Programs.git] / perl / smtp3.pl
CommitLineData
21c4e167
H
1#!/usr/bin/env perl
2use strict;
3use warnings;
4use IO::Socket::INET;
5
6$netdns = eval 'use Net::DNS';
7if($netdns) use Net::DNS;
8
9my $from='harvie@harvie.cz';
10my $rcpt='harvie@email.cz';
11my $subj='Subj3ct';
12my $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
15my @rcpts = split('@', $rcpt);
16
17
18if($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
35my $data = <<END
36HELO $rcpts[1]
37MAIL FROM:<$from>
38RCPT TO:<$rcpt>
39DATA
40From: <$from>
41To: <$rcpt>
42Subject: $subj
43
44$mesg\r\n.\r\nQUIT
45END
46;
47
48my $sock = IO::Socket::INET->new(PeerAddr => $xchg, PeerPort => '25');
49print "SRV: ".<$sock>;
50print $data;
51print $sock $data;
52while(<$sock>) {
53 print "SRV: ".$_;
54 STDOUT->flush;
55}
56
57$sock->close;
58
This page took 0.439741 seconds and 4 git commands to generate.