Re: [ILUG] Looking for Information

From: Peter Heslin (Peter.Heslin at domain ucd.ie)
Date: Thu 03 Feb 2000 - 02:58:01 GMT


On Wed, Feb 02, 2000 at 02:30:34PM -0000, Eleanor Duff wrote:
> Does anyone anything about converting a Perl script from Linux/Unix for
> use in an NT enviornment?
> I have a contact HTML form running off an Apache Server. Aperl script
> grabs the information, puts it to the screen in HTML format, so the
> customer can see what they have sent, the it opens the sendmail utility
> on the Unix box and sends it to me in the format of an e-mail with the
> data collected, listed in it.

I've heard that Sendmail has been ported to NT, so installing that
might be one way to go (but I have no experience with it myself).

> I wish to replicate the forms on my IIS server, and use the Perl forms
> to call a MS-DOS based mailing program. Is there anyway of doing this
> conversion, a utility or script I can use that will allow the batch file
> to be called?
>

You could easily rewrite the relevant bit of the script to use a more
platform independent module instead of calling sendmail directly.
Install the MailTools bundle on the NT box by downloading the .ppm
binary from www.activestate.com. Then install it on the linux box:
perl -MCPAN -e shell and type install Mail::Send at the prompt.

Cutting and pasting from the manual, the code you need to write will
look something like this:

require Mail::Send;

$msg = new Mail::Send;

$msg = new Mail::Send Subject=>'example subject', To=>'user at domain host';

# Launch mailer and set headers. The filehandle returned
# by open() is an instance of the Mail::Mailer class.

$fh = $msg->open;

# This is where you output your data, using the print command.

print $fh "Body of message";

$fh->close; # complete the message and send it

                
HTH,
Peter

Check
out the documentation to Mail::Mailer. IIRC, it tries several
options: it'll use Sendmail if its available, but failing that, it can
send SMTP directly to the server of your choice. There's a note on this
in perldoc perlfaq9 and for all the mail modules you could want, see:
http://search.cpan.org/search?mode=module&query=mail

Make sure that the module of your choice is also available as a .ppm
binary for Windows at www.activestate.com. I see a bundle there
called MailTools, which should contain Mail::Send. Once your improved
script runs on the Linux box, it should then run on NT, provided that
the necessary module has been installed there.

Peter



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:05:20 GMT