Solved

Sending mail from IIS similar to Unix sendmail

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

708 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

14 Experts available now in Live!

Get 1:1 Help Now