Solved

Sending mail from IIS similar to Unix sendmail

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

827 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