Solved

Sending mail from IIS similar to Unix sendmail

Posted on 1998-02-25
4
201 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
i want to read the contents of the file to Csv 13 53
Choosing the right PHP framework for web develpment 8 91
Need to Modify a Script I found 5 93
Where do I learn ES6? 3 51
This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now