The whole purpose was not Win32 compat.
It is not a "trial". It is a homework exercise - assigned individually
to each student, and I got this...
Indeed, I have realised, before asking, that I will have to talk
directly to the DNS server. But I was looking for some perl-specific
sample code on the DNS query - the rest is easy for me.
I do have permission by the subject supervisor to obtain THIS SEPECIFIC
help from a forum or newsgroup of some kind, I contacted my supervisor
abou that.
The only piece of code which I would need is to talk directly to the
DNS server.
as follows are some dirty code from an old Chinese BBS script:
sub smtpmail {
if ($main::loadsocketmo ne 1) { eval("use Socket;");
$main::loadsocketmo = 1; }
my ($address, $from, $replyaddr, $subject, $body, $extra) = @_;
$body = Base64encode($body);
$subject = mimeencode($subject);
my $tempname = mimeencode($main::boardname);
my ($name, $aliases, $proto, $type, $len, $thataddr);
my @to = split(/, /, $address);
foreach my $i (@to) {
my $AF_INET = 2;
my $SOCK_STREAM = 1;
my $SOCKADDR = 'S n a4 x8';
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $type, $len, $thataddr) =
gethostbyname($main::SMTP_SERVER);
my $this = pack($SOCKADDR, $AF_INET, 0);
my $that = pack($SOCKADDR, $AF_INET, $main::SMTP_PORT, $thataddr);
socket(S, $AF_INET, $SOCK_STREAM, $proto);
bind(S, $this);
connect(S, $that);
select(S);
$| = 1;
select(STDOUT);
my $a = <S>;
if ($a !~ /^2/) {
close(S);
undef $|;
return $a;
}
if ($extra eq "no") {
print S "HELO localhost\r\n";
$a = <S>;
} else {
print S "EHLO localhost\r\n";
$a = <S>;
print S "AUTH LOGIN\r\n";
$a = <S>;
my $encode_smtpuser = &Base64encode($main::SMTPUSER);
print S "$encode_smtpuser\r\n";
$a = <S>;
my $encode_smtppass = &Base64encode($main::SMTPPASS);
print S "$encode_smtppass\r\n";
$a = <S>;
return $a if ($a =~ /fail/i);
}
print S "MAIL FROM: <$from>\r\n";
$a = <S>;
print S "RCPT TO: <$i>\r\n";
$a = <S>;
print S "DATA\r\n";
$a = <S>;
print S "From: $tempname<$from>\r\n";
print S "To: $i\r\n";
print S "Subject: $subject\r\n";
print S "Reply-To: $tempname<$replyaddr>\r\n" if ($replyaddr);
print S "X-Mailer: LeoBBS eSmtp Mail Sender\r\n";
print S "Content-Type: text/html; charset=gb2312\r\n";
print S "Content-Transfer-Encoding: base64\r\n\r\n";
print S "$body\r\n";
print S "\r\n\r\n";
print S ".\r\n";
$a = <S>;
print S "QUIT\r\n";
$a = <S>;
close(S);
undef $|;
}
return 1;
}
sub mimeencode {
my $str = shift;
return '=?gb2312?B?'.Base64encode($str).'?=';
}
sub Base64encode {
my $res = pack("u", $_[0]);
$res =~ s/^.//mg;
$res =~ s/\n//g;
$res =~ tr|` -_|AA-Za-z0-9+/|;
my $padding = (3 - length($_[0]) % 3) % 3;
$res =~ s/.{$padding}$/'=' x $padding/e if $padding;
return $res;
}
this may help. use it at your own risk. ;-)