What is sendmail?
If we look in the Internet, sendmail is the most popular Unix-based implementation of the Simple Mail Transfer Protocol (SMTP) for transmitting e-mail. When a sendmail server receives e-mail, it attempts to deliver the mail to the intended recipient. However, because it does not provide a mailbox facility and for other reasons, other software such as a POP3 or Internet Message Access Protocol server are also needed. Most Internet service providers (ISPs) provide both an SMTP server (such as sendmail) and a POP or IMAP server.
As said sendmail is Unix-based program so it does not work on windows systems. But there are sendmail.exe programs for windows based systems. In further text I'll describe it and show you how to implement it in windows 2003 server and IIS.
How does sendmail for windows work?
In perl or php or asp scripts we can write a code to send mail to mail recepients. We direct data to program sendmail.exe who sends email to person or persons that our script sends. So all we need is to send header and email-msg to sendmail.exe program and that is it.
Installation of sendmail.exe
When you create a web page and upload it via ftp it is usualy in folde c:\Inetpub\wwwroot\testdomain.com\httpdocs\. All of scripts are in cgi-bin folder (for example c:\Inetpub\wwwroot\testdomain.com\httpdocs\cgi-bin\). "Cgi-bin" folder must have execute permissions.
|for webpages user for web access is usualy IUSR_???? and it has to have those permissions
Link for downloading sendmail.exe program and settingssendmail.ini script is here (sendmail.zip).
Now upload sendmail.zip to your cgi-bin folder end extract contents.
|This is the contents of cgi-bin\sendmail folder
Next step is to edit sendmail.ini file. You only need to set your domain and if you do not have your own smtp server installed on your server you can write smtp mail server of your internet service provider.
|Example of settings in sendmail.ini file
Text source of sendmail.ini:
; configuration for fake sendmail
; you must change mail.mydomain.com to your smtp server
; smtp.amis.net smtp.volja.net
; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify
; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging
; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging
; if your smtp server requires authentication, uncomment and modify the
; following two lines
; if your smtp server uses pop3 before smtp authentication, uncomment and
; modify the following three lines
in next step you must change permissions to write for "IUSR_????" so sendmail.exe can write to debug and error files. Those two files can later be used to analyze problems and errors of you scripts for sending mail.
|Setting permissions of debug.log and error.log files
That is it. You have successfully installed sendmail.exe program for windows - now only thing for you is to use it...
Example of sendmail sending mail from perl (cgi-bin) script
|Here is example of sending mail - perl code
Perl text script source is:
print "Content-type: text/html\n\n";
open SENDMAIL, "|sendmail/sendmail.exe -t" or die "$0: fatal: could not open sendmail: $!\n";
print SENDMAIL "To: user\@example.com\n";
print SENDMAIL "Subject: Title of the Subject\n\n";
#And now the body of mail
print SENDMAIL "This is a test mail\n";
print SENDMAIL "from webpage velikan.net\n";
print SENDMAIL "\n";
print SENDMAIL "Etc ... etc ...\n";
You can also download this test code (example_sendmail_for_windows.zip) and extract it in your cgi-bin folder. You can test and execute the code by typing address of this script (for example http://localhost/cgi-bin/example_sendmail_for_windows.pl or http://www.yourdomain.com/cgi-bin/example_sendmail_for_windows.pl) - or also you can add a button in html file and point it to url of script.
Other webpages also dedicated to sendmail:
sendmail from Wikipedia
sendmail official website
O'Reilly Media - sendmail
|This tutorial can be used with windows server 2003, windows server 2000, windows XP and windows XP proffessional. If you find this tutorial to be usefull please add link to it http://www.velikan.net/sendmail-for-windows-iis so other people will also find this tutorial page.