NTsendmail NTsendmail is a free Perl module (GNU License) to enable sending mail from NT servers. NTsendmail was specifically designed to enable script writers to use their UNIX CGIs on NT servers. NTsendmail also works on UNIX / Linux PROBLEM: You have a UNIX CGI written in Perl which sends mail by opening a pipe to sendmail and feeding it a mail message. E.g.: #! /usr/bin/perl -w $|=1; $sendmail = "/usr/lib/sendmail"; open (MAIL, "| $sendmail -t -f \'tester\@1testdomain.com\'") || die ("Opening pipe failed."); print MAIL "From: tester\@1testdomain.com\r\n"; print MAIL "To: tester\@1testdomain.com\r\n"; print MAIL "Subject: Message from NTsendmail\r\n"; print MAIL "Hi there. It's a wonderful day outside, isn't it?\r\n"; close (MAIL); exit 0;You soon realize that NT doesn't have sendmail, or any other means of sending mail from the command line. SOLUTION:
$ENV{"NTsendmail"} = "smtp.mydomain.com"; "use NTsendmail;" $mail = new NTsendmail; $mail->send($sender, $recipient, $subject, $message); * %ENV is the environment variable hash in Perl.
SECURITY, CONFORMITY: You might have noticed that NTsendmail calls the local mailserver, or another mailserver which accepts mail from your machine. This is done to guarantee that all mail handling, caching, etc. is done according to the same rules as all your other mail. This method of specifying a mailserver also allows you to run Perl CGIs on a server without a mailserver, using another machine's mailserver instead. By utilizing a mailserver behind a firewall, this feature can be used to complement your company's security policies for mail. NTsendmail is a true plug and play solution, instead of requiring complex configurations of its own. You plug it in and use it. That's all there is to it. REQUIREMENTS: You must have Perl installed on your NT system. (Tested on Perl 5. Perl 4 might work.) Requires the Socket module to be installed. If you are not sure whether you have it, look for a file called socket.pm in the Perl lib directory. (Usually, c:\\perl\lib\socket.pm).
DEBUGGING:
If you define $ENV{"NTsendmail_debug"} in your script,
you will get verbose error messages and the body of
the emails sent also contains the number of attempts
made in the process.
|