Solved

Sending mail from IIS similar to Unix sendmail

Posted on 1998-02-25
4
203 Views
Last Modified: 2013-12-25
I have written many many cgi scripts to send mail from different unix machines, but now I have a need to move these scrips to an NT 40 server machine running IIS. I would like for the answer to tell me where to get any code required to send mail, and also a snippet of code that calls the routines required to send the mail. Perl is preferred.

Angel
0
Comment
Question by:airborne
4 Comments
 

Author Comment

by:airborne
ID: 1832039
I quickly increased the points because I want a quick correct answer. I will give more points, depending on the completeness of the answer.

0
 
LVL 1

Expert Comment

by:buemoh
ID: 1832040
Hi airbone,

if you wrote PERL scripts, then you're normaly using the program SENDMAIL, which is available on each unix machine. There are some implementations of SENDMAIL for WindowsNT available on some FTP-servers, but I think, the best way to do ist, build an ISAPI .DLL and use WINSOCK for sending an e-mail.

ISAPI .DLLs can be written with each programming language under WindowsNT, like VC++, BCC++, Delphi 2 or 3, ...

But first, look on the net, there are som good ISAPI implementations to let the user fill in a formular and send it.

If you need an example source, tell me and you'll get it.
0
 
LVL 32

Accepted Solution

by:
jhance earned 200 total points
ID: 1832041
Here's a PERL script that send mail via SMTP to a mail server.  Be careful, however, to choose a PERL port on NT that supports sockets.  Not all do.


#!/bin/perl
# Perl Program to send a message via SMTP

($them, $port) = @ARGV;
$port = 25 unless $port;
$them = 'localhost' unless $them;

$AF_INET = 2;
$SOCK_STREAM = 1;

$sockaddr = 'S n a4 x8';

($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port)  = getservbyname($port, 'tcp') unless $port =~ /^\d+$/;;

($name, $aliases, $type, $len, $thisaddr) = gethostbyname('localhost');
($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);

$this = pack($sockaddr, $AF_INET, 0, $thisaddr);
$that = pack($sockaddr, $AF_INET, $port, $thataddr);

if(socket(S, $AF_INET, $SOCK_STREAM, $proto)){
  print "socket ok\n";
}
else{
  die $!;
}

if(bind(S, $this)){
 print "bind ok\n";
}
else{
 die $!;
}

if(connect(S, $that)){
  print "connect ok\n";
}
else{
  die $!;
}

select(S); $| = 1; select(STDOUT);

$_ = <S>;
print;
print S "HELO myhost.com\n";
print S "MAIL FROM: myemail@myhost.com\n";
print S "RCPT TO: destemail@desthost.com\n";
print S "DATA\n";
print S "This is just a test message\n";
print S ".\n";
print S "QUIT\n";

print "done\n";

0
 

Expert Comment

by:manningc
ID: 1832042
I have successfully used a freeware program called 'blat'.
I found this utility on the site www.davecentral.com, which
is a software archive site.  The site describes this utlity
thusly:

"Blat is a public domain Windows NT console                      (DOS) utility that sends the contents of a file in                       an e-mail message using the SMTP protocol.                       Perfect for use with CGI scripts that need to                       send e-mail. Source code and sample cgi                       scripts also available. Some users claim it                       works fine in Windows 95 as well."

This utility requires that you first construct
the message in a temporary file, then send it by invoking
the utility.  
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question